allow string based values for comboboxarray
[roojs1] / Roo / doc / Example.js
index 2fa7b0e..5ae32f0 100644 (file)
@@ -7,9 +7,11 @@
  * @class Roo.doc.Example
  * @extends Roo.bootstrap.Component
  * Example Element class
- * @cfg {String} lang (phpcode|programlisting) section type.
+ * @cfg {String} title short title describing example
+ * @cfg {String} lang (php|txt|sql) code language.
  * @cfg {String} code  example code
  * @cfg {String} output The expected output from the code
+ * @cfg {String} outputlang php|txt|sql) output language
  *
  * 
  * @constructor
@@ -27,42 +29,52 @@ Roo.extend(Roo.doc.Example, Roo.bootstrap.Component,  {
     lang:   'php',
     code : '',
     output : '',
+    outputlang : 'txt',
     
     getAutoCreate : function(){
         
         // no colour highlighting in here....
         
+        var code = hljs ? hljs.highlight(this.lang,this.code).value :
+                String.format('{0}',this.code).replace(/\n/g, '<br/>');
+        
+        Roo.log("code=" + code);
         var cfg ={
-            
-            
             cls : 'panel panel-info',
-            
             cn : [
                 {
-                    tag: 'pre',
-                    cls : this.lang,
-                    html :  String.format('{0}',this.code).replace(/\n/g, '<br/>')
+                    cls : 'panel-heading',
+                    html : this.title
+                },
+                {
+                    cls : 'panel-body',
+                    cn : [
+                        {
+                            tag: 'pre',
+                            cls : 'lang-' + this.lang,
+                            html :  code
+                        }
+                    ]
                 }
             ]
         };
+        
         if (this.output) {
-            cfg.cn.push({
-                cls : 'panel panel-success',
-                cn : [
-                    {
-                        cls : 'panel-heading',
-                        html : "Outputs",
-                    },
-                    {
-                        cls : 'panel-body',
-                        cn : {
-                            tag: 'pre',
-                            html :  String.format('{0}',this.output).replace(/\n/g, '<br/>')
-                        }
+            
+            var out = hljs ? hljs.highlight(this.outputlang,this.output).value :
+                    String.format('{0}',this.output).replace(/\n/g, '<br/>');
+            cfg.cn.push(
+
+                {
+                    cls : 'panel-footer',
+                    cn : {
+                        tag: 'pre',
+                        html : out 
                     }
-                ]
+                }
+            
                 
-            });
+            );      
         }