<{literal}>

<{literal}> タグに囲まれたデータのブロックは、リテラルとして認識されます。これは一般的に、Javascript やスタイルシートなどで中括弧がテンプレートの デリミタ として解釈されるとまずい場合に使用します。ただし、Simplate の場合はデフォルトデリミタが <{ }> なので、通常、<{literal}> タグを使用することはありません。<{literal}><{/literal}> タグの内部は解釈されず、そのままで表示されます。

例. <{literal}> タグ
  1. <{literal}>
  2. <script type="text/javascript">
  3. <!--
  4. function isblank(field)
  5. {
  6. if (field.value == ''){
  7. return false;
  8. } else {
  9. document.loginform.submit();
  10. return true;
  11. }
  12. }
  13. // -->
  14. </script>
  15. <{/literal}>
例. Javascript の関数の例
  1. <script language="JavaScript" type="text/javascript">
  2. <{literal}>
  3. function myJsFunction(name, ip)
  4. {
  5. alert("The server name\n" + name + "\n" + ip);
  6. }
  7. <{/literal}>
  8. </script>
  9. <a href="javascript:myJsFunction('<{$SERVER_NAME}>', '<{$SERVER_ADDR}>')">Click here for the Server Info</a>
例. テンプレート内での css style
  1. <{* included this style .. as an experiment *}>
  2. <style type="text/css">
  3. <{literal}>
  4. /* this is an intersting idea for this section */
  5. .madIdea{
  6. border: 3px outset #ffffff;
  7. margin: 2 3 4 5px;
  8. background-color: #001122;
  9. }
  10. <{/literal}>
  11. </style>
  12. <div class="madIdea">With smarty you can embed CSS in the template</div>