• ベストアンサー

Smartyで { や } を使いたい

maguro999の回答

  • ベストアンサー
  • maguro999
  • ベストアンサー率21% (59/273)
回答No.2

http://smarty.php.net/manual/ja/language.escaping.php left_delimiterとright_delimiterでSmartyでのデフォルトの デリミタを変更するか http://smarty.php.net/manual/ja/language.function.literal.php で必要なところだけ回避させる。 プログラマ側の都合で回避するか デザイナ側の都合で回避するかの違いですね。

usb_memory
質問者

お礼

{literal}を使う事で無事回避できました。 ありがとうございました。

関連するQ&A

  • Smartyのエラーが2つずつ出ます

    PHP5+Smartyでサイトを作っています。 「$smarty->display("hoge.tpl");」としてテンプレートファイルを呼び出します。 そのテンプレートファイル「hoge.tpl」が存在しない時に、以下のエラー文が必ず2つ表示されます。 Warning: Smarty error: unable to read resource: "hoge.tpl" in /root/.../smarty/Smarty.class.php on line 1092 一度しか呼び出していないのにエラーが2つ表示されるので、コードの記述ミスかと考えたのですがわかりませんでした。 テンプレートファイルがある場合は、テンプレートが二度呼び出されることはありません。 エラー文にある1092行目からコードを追って見たのですがわかりませんでした。 どうすればエラー表示を1つにできるのでしょうか? 宜しくお願いします。

    • 締切済み
    • PHP
  • smartyについて

    phpからassignしテンプレートに表示するには問題ないのですがテンプレートでassignし 表示させたく単純に以下のようにしてみましたがエラーになってしまいます。 <{assign var="aaa"value="名前"}> <{$aaa}> ※デリミタ設定は『<{』と『}>』で指定してます エラー内容は以下の通りです。 Fatal error: Smarty error: [in テンプレートファイル line assignしている行]: syntax error: invalid attribute name: '=' (Smarty_Compiler.class.php, line 1550) in ~中略~\Smarty\Smarty.class.php on line 1093 なんとなくではありますが'='が原因のような事はわかるのですが解決できずにおります。 この場合どうすればいいのでしょうか?

    • ベストアンサー
    • PHP
  • Smartyについて教えてください。

    Smartyについて教えてください。 参考書によってテンプレートの存在するディレクトリを指定している場合(1)と していない場合(2)がありますが、 どちらが正しいのでしょうか? (1) ********************************************* require_once('smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = "template02/"; $smarty->compile_dir = "compile/"; $smarty->display("content.tpl"); ********************************************* (2) ********************************************* require_once('smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->display("content.tpl"); *********************************************

    • ベストアンサー
    • PHP
  • smartyで文字化け

    Smarty(テンプレートエンジン)を使用しています。 テンプレートの中で『本』や『ボ』といった文字を使用すると文字化けします。 原因としてはこれらの文字の2バイト目が『{』と同じなのでSmartyでコンパイルする時にタグとして見られてしまっている様子…。 回避策はないでしょうか?

    • 締切済み
    • PHP
  • smarty3で変数表示について

    smarty3 でエラーが発生しています。 現在自宅のサーバーでsmarty3を勉強しているのですが以下のエラーで困っています。 詳しい方ご教授お願いします。 環境 : CentOS 6.3 PHP 5.3.3 Smarty 3.1.13 読み込んでいるファイル test.php 1 <?php 2 ini_set('display_errors', 1); 3 ini_set('date.timezone','Asia/Tokyo'); 4 define('SMARTY_DIR', 'Smarty/libs/'); 5 require_once( SMARTY_DIR. 'Smarty.class.php'); 6 7 $smarty = new Smarty(); 8 9 $smarty->template_dir = '../templates/'; 10 $smarty->compile_dir = '../templates_c/'; 11 $smarty->config_dir = '../config/'; 12 $smarty->cache_dir = '../cache/'; 13 14 $msg = "テストを表示します"; 15 $smarty->assign('msg', $msg); 16 17 $smarty->display('test.tpl'); 18 19 20 ?> テンプレートファイル 1 <html> 2 {$msg} 3 </html> 表示されるエラー文 Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "../templates/test.tpl" on line 2 "{$msg}" unknown tag "private_print_expression"' in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php:665 Stack trace: #0 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(451): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "pr...', 2) #1 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(2353): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e...', Array, Array) #2 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3101): Smarty_Internal_Templateparser->yy_r27() #3 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3201): Smarty_Internal_Templateparser->yy_reduce(27) #4 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_intern in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 665 テンプレートファイルの{$msg}を削除して動作させるとコンパイルされてはいるようです。 よろしくお願いします。

    • 締切済み
    • PHP
  • Smartyエラーについて

    いつもお世話になっております。 Smartyのエラーが解決できなくて困っています。 お手数ですが、後教授願えないでしょうか。 使用環境:Ubuntu Eclipse [エラー] Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 /home/mobapendev/public_html/Smarty/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 /home/mobapendev/public_html/Smarty/Smarty.class.php(382): Smarty->fetch('list.tpl', NULL, NULL, NULL, true) #3 /home/mobapendev/public_html/mobapen/list.php(20): Smarty->display('list.tpl') #4 {main} thrown in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php on line 163 ディレクトリ構成 Smarty/Smarty.class.php Project/list.php Project/php/common.php project/smarty/templates/list.tpl project/smarty/templates_c project/smarty/cache project/smarty/configs となっており、 common.phpにて、 $dir = getcwd(); $smarty->template_dir=$dir .'/smarty/templates'; $smarty->compile_dir=$dir .'/smarty/templates_c'; $smarty->config_dir=$dir .'/smarty/configs'; $smarty->cache_dir =$dir .'/smarty/cache'; list.phpにて require_onceで取り込みまいしたが、 $smarty->display("list.tpl"); ディレクトリは間違っていないとは思っているのですが、 どこでload出来てていなか分からず、攻め上げいている状況です。 以上、宜しくお願い致します。

    • ベストアンサー
    • PHP
  • smartyについて

    smartyについて 環境は、windows /php-5 / smarty-2.6.17です。 以下の2つエラーが出てどう対処すればいいか困っています。 【1つめ】 Fatal error: Smarty error: [in **.tpl line 10]: syntax error: unrecognized tag: 文--> 【2つめ】 {$errmsg (Smarty_Compiler.class.php, line 446) in C:\xampp\php\PEAR\Smarty\libs\Smarty.class.php on line 1095 【ソース】 呼び先PGは、 $this->smarty->assign("errmsg","ニックネーム"); $this->smarty->display("**.tpl"); テンプレートでは、 <tr id="" class=""> <td id="" class=""><font color="#ff0000">{$errmsg}を入力してください。</font></td> </tr> よろしくお願いいたします。

    • 締切済み
    • PHP
  • Smartyの[]内に[]を使いたいです。

    {$a[$b['id']].cnt} のように、[ ] の中に[ ] を記述すると Smartyの文法エラーになってしまいます。 何か記述方法はあるでしょうか?

    • ベストアンサー
    • PHP
  • Smartyのテンプレートからjavascriptに配列を渡す

    お世話になります。 PHP+Smartyで開発しております。 質問なのですが、 PHPからSmartyに連想配列をアサインします。 そして、そのテンプレートよりjavascriptへ配列を渡すことは 可能でしょうか? もし可能でしたら、ご教授願えないでしょうか。 よろしくお願いいたします。

    • ベストアンサー
    • PHP
  • Smartyでテンプレートが読み込めない

    下記のソースを実行すると、テンプレートが読み込めずエラーになってしまいます。 うーん、何故なのか分からず困っております。 phpのバージョンは4.4.6なのですが、Ver5以降でないとサポートされないのでしょうか。 [source] <?php require_once("Smarty.class.php"); class MySmarty extends Smarty { function _MySmarty() { $this->Smarty(); $this->template_dir="../templates"; $this->compile_dir="../templates_c"; } } $o_smarty=new MySmarty(); $o_smarty->display("hello.tpl"); ?> [error message] Warning: Smarty error: unable to read resource: "hello.tpl"

    • ベストアンサー
    • PHP