Roo/doc/Example.js
[roojs1] / Roo / doc / Example.js
1 /*
2  * - LGPL
3  *
4  */
5
6 /**
7  * @class Roo.doc.Example
8  * @extends Roo.bootstrap.Component
9  * Example Element class
10  * @cfg {String} title short title describing example
11  * @cfg {String} lang (php|txt|sql) section type.
12  * @cfg {String} code  example code
13  * @cfg {String} output The expected output from the code
14  *
15  * 
16  * @constructor
17  * Create a new Synopsis
18  * @param {Object} config The config object
19  */
20
21 Roo.doc.Example = function(config){
22     Roo.doc.Example.superclass.constructor.call(this, config);
23 };
24
25 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component,  {
26     
27     title : '',
28     lang:   'php',
29     code : '',
30     output : '',
31     
32     getAutoCreate : function(){
33         
34         // no colour highlighting in here....
35         
36         var code = hljs ? hljs.highlight(this.lang.toUpperCase(),this.code) : String.format('{0}',this.code).replace(/\n/g, '<br/>');
37         
38         
39         var cfg ={
40             cls : 'panel panel-info',
41             cn : [
42                 {
43                     cls : 'panel-heading',
44                     html : this.title
45                 },
46                 {
47                     cls : 'panel-body',
48                     cn : [
49                         {
50                             tag: 'pre',
51                             cls : 'lang-' + this.lang,
52                             html :  code
53                         }
54                     ]
55                 }
56             ]
57         };
58         
59         if (this.output) {
60             cfg.cn.push(
61
62                 {
63                     cls : 'panel-footer',
64                     cn : {
65                         tag: 'code',
66                         html :  String.format('{0}',this.output).replace(/\n/g, '<br/>')
67                     }
68                 }
69             
70                 
71             );
72         }
73         
74         
75         
76         return cfg;
77     }
78   
79     
80     
81    
82 });
83
84  
85
86