index.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <!doctype html>
  2. <title>CodeMirror: Smarty mixed mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../mode/xml/xml.js"></script>
  8. <script src="../../mode/javascript/javascript.js"></script>
  9. <script src="../../mode/css/css.js"></script>
  10. <script src="../../mode/htmlmixed/htmlmixed.js"></script>
  11. <script src="../../mode/smarty/smarty.js"></script>
  12. <script src="../../mode/smartymixed/smartymixed.js"></script>
  13. <div id=nav>
  14. <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  15. <ul>
  16. <li><a href="../../index.html">Home</a>
  17. <li><a href="../../doc/manual.html">Manual</a>
  18. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  19. </ul>
  20. <ul>
  21. <li><a href="../index.html">Language modes</a>
  22. <li><a class=active href="#">Smarty mixed</a>
  23. </ul>
  24. </div>
  25. <article>
  26. <h2>Smarty mixed mode</h2>
  27. <form><textarea id="code" name="code">
  28. {**
  29. * @brief Smarty mixed mode
  30. * @author Ruslan Osmanov
  31. * @date 29.06.2013
  32. *}
  33. <html>
  34. <head>
  35. <title>{$title|htmlspecialchars|truncate:30}</title>
  36. </head>
  37. <body class="{$bodyclass}">
  38. {* Multiline smarty
  39. * comment, no {$variables} here
  40. *}
  41. {literal}
  42. {literal} is just an HTML text.
  43. <script type="text/javascript">//<![CDATA[
  44. var a = {$just_a_normal_js_object : "value"};
  45. var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
  46. mode : "smartymixed",
  47. tabSize : 2,
  48. indentUnit : 2,
  49. indentWithTabs : false,
  50. lineNumbers : true,
  51. smartyVersion : 3
  52. });
  53. // ]]>
  54. </script>
  55. <style>
  56. /* CSS content
  57. {$no_smarty} */
  58. .some-class { font-weight: bolder; color: "orange"; }
  59. </style>
  60. {/literal}
  61. {extends file="parent.tpl"}
  62. {include file="template.tpl"}
  63. {* some example Smarty content *}
  64. {if isset($name) && $name == 'Blog'}
  65. This is a {$var}.
  66. {$integer = 4511}, {$array[] = "a"}, {$stringvar = "string"}
  67. {$integer = 4512} {$array[] = "a"} {$stringvar = "string"}
  68. {assign var='bob' value=$var.prop}
  69. {elseif $name == $foo}
  70. {function name=menu level=0}
  71. {foreach $data as $entry}
  72. {if is_array($entry)}
  73. - {$entry@key}
  74. {menu data=$entry level=$level+1}
  75. {else}
  76. {$entry}
  77. {* One
  78. * Two
  79. * Three
  80. *}
  81. {/if}
  82. {/foreach}
  83. {/function}
  84. {/if}
  85. </body>
  86. <!-- R.O. -->
  87. </html>
  88. </textarea></form>
  89. <script type="text/javascript">
  90. var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
  91. mode : "smartymixed",
  92. tabSize : 2,
  93. indentUnit : 2,
  94. indentWithTabs : false,
  95. lineNumbers : true,
  96. smartyVersion : 3,
  97. matchBrackets : true,
  98. });
  99. </script>
  100. <p>The Smarty mixed mode depends on the Smarty and HTML mixed modes. HTML
  101. mixed mode itself depends on XML, JavaScript, and CSS modes.</p>
  102. <p>It takes the same options, as Smarty and HTML mixed modes.</p>
  103. <p><strong>MIME types defined:</strong> <code>text/x-smarty</code>.</p>
  104. </article>