flexy:if="variable or method()"

flexy:if="variable or method()" – PHP の if 条件タグを作成する

Synopsis

使用法 ( flexy:if="variable" , flexy:if="method()" , flexy:if="object.method()" )

Description

含まれるタグを囲む if 条件を作成します。

Parameter

  • string variable - $object->variable に関連します。

  • string method - $object->method() に関連します。

  • string object.method $object->object->method() に関連します。

Example

foreach 用の変数の設定

         
class output {
    function hasTest() {
        return false;
    }
    
    function run() {
        $this->a = true;
        $this->message = 'oops'
        $template->outputObject($this);
    }
}

テンプレートにおける flexy:if

   

<a href="{baseURL}/somepath.html" flexy:if="a">this is the a link</a>
<a href="{baseURL}/somepath.html" flexy:if="!a">this is not the a link</a>
<b flexy:if="hasTest()">hasTest is true</b>
<b flexy:if="!hasTest()">hasTest is false</b>

<span flexy:if="message" class="error">{message}</span>

コンパイルされたテンプレート

         
       
 
<?php if ($t->a)  { ?><A HREF="<?php echo htmlspecialchars($t->baseURL); ?>/somepath.html">this is the a link</A><?php } ?>
<?php if (!$t->a)  { ?><A HREF="<?php echo htmlspecialchars($t->baseURL); ?>/somepath.html">this is not the a link</A><?php } ?>
<?php if (isset($t) && method_exists($t,'hasTest')) if ($t->hasTest()) {  ?><B>hasTest is true</B><?php } ?>
<?php if (isset($t) && method_exists($t,'hasTest')) if (!$t->hasTest()) {  ?><B>hasTest is false</B><?php } ?>
 
<?php if ($t->message)  { ?><SPAN CLASS="error"><?php echo htmlspecialchars($t->message); ?></SPAN><?php } ?>

シンプルな出力例

         
      
this is the a link
hasTest is false

oops
NPO法人の設立はお任せ下さい

NPO法人とはという基本的内容から実際のNPO法人設立まで広くお手伝いいたします。これからNPO法人をお考えの方はオススメ。NPO法人とはNon Profit Organizationの略であり、特定非営利活動法人を指します。法人なので当然に登記され、独立した人格として活動ができるようになります。

これから引越しや転勤等で賃貸物件を探すなら、賃貸大阪homeへ
アクセスカウンター
アルバイトをお探しならアルバイトスタイルへ。アルバイトを探したい方、アルバイトを探している方は必見です。
NPO法人をこれから設立したいとお考えなら自分で設立するNPO法人へ。都道府県ごとのNPO法人設立情報などを提供。NPO法人証明書も発行
株式会社をこれから設立したいとお考えなら会社設立webへ。都道府県ごとの会社設立専門家を紹介しております。
メールフォームを製作するならメールフォームbizへ。納品できるメールフォームを製作