YiiML Reference

an overview of the library


Note this is only documenting the Yii specific syntax added by the YiiCL extension to peml. For details on the core syntax and extension possibilities, please see the peml website.


:widget and :partial

These functions are available both inside and out of :php blocks, and take an optional indented list of arguments to pass in.

YiiML

#right-column
  :php
    :widget application.components.SearchWidget
      query : isset($_GET['q']) ? $_GET['q'] : ""
      ajax  : true
      admin : user()->checkAccess("Admin")
    :widget application.components.Login
  :partial _item
    item : $model

PHP

<div id="right-column">
  <?php
    $this->widget("application.components.SearchWidget",
      array("query"=>isset($_GET['q']) ? $_GET['q'] : "",
      "ajax"=>true,
      "admin"=>user()->checkAccess("Admin"),
    ));
    $this->widget("application.components.Login");
  ?>
  <?php $this->renderPartial("_item", array("item"=>$model)); ?>
</div>

:form and :chtml

These provide additional shortcuts for CHtml::beginForm() and CHtml:: methods.

YiiML

:form
  fieldset#userprofile
    legend Form Title
    p.username
      :chtml activeLabelEx($model, 'name')
      :chtml activeTextField($model,'name')
    p.profile
      :chtml activeLabelEx($model, 'profile')
      :chtml activeTextArea($model,'profile')
    p.submit
      :chtml submitButton('Submit')

PHP

<?php echo CHtml::beginForm(); ?>
  <fieldset id="userprofile">
    <legend>Form Title</legend>
    <p class="username">
      <?php echo Chtml::activeLabelEx($model, 'name'); ?>
      <?php echo Chtml::activeTextField($model,'name'); ?>
    </p>
    <p class="profile">
      <?php echo Chtml::activeLabelEx($model, 'profile'); ?>
      <?php echo Chtml::activeTextArea($model,'profile'); ?>
    </p>
    <p class="submit">
      <?php echo Chtml::submitButton('Submit'); ?>
    </p>
  </fieldset>
<?php echo CHtml::endForm(); ?>