pavlinter / yii2-dot
Yii2: doT javascript template
Installs: 1 837
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Language:JavaScript
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-12-21 18:33:55 UTC
README
Widget for doT.js script
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist pavlinter/yii2-dot "dev-master"
or add
"pavlinter/yii2-dot": "dev-master"
to the require section of your composer.json
file.
Usage
<?php $data = [ [ 'name' => 'Jim', 'age' => '35', 'msg' => 'Pellentesque non felis ligula', ], [ 'name' => 'Robert', 'msg' => 'Cras sagittis dapibus lacus', ], [ 'name' => 'Maikl', 'age' => '12', ], [ 'msg' => 'Cras sagittis dapibus lacus', ], ]; $this->registerJs(' var data = ' . Json::encode($data) .'; $("#comment-box-html").tmplHtml("comment", data); $("#comment-box-append").tmplAppend("comment", data); //append each $("#comment-box-prepend").tmplPrepend("comment", data); //prepend each '); ?> <div id="comment-box-html"></div> <div id="comment-box-append"></div> <div id="comment-box-prepend"></div> <?php \pavlinter\doT\DoT::begin(['id' => 'comment']) ?> <div class="media"> <div class="media-body"> <div class="media-heading"> {{=it.name || 'Anonymous'}} {{? it.age }} <span class="label label-info">{{=it.age}}</span> {{?}} </div> {{? it.msg }} <p>{{=it.msg}}</p> {{?}} </div> </div> <?php \pavlinter\doT\DoT::end() ?>