EmberJS 模板Link To内联助手
描述
通过将链接文本指定为辅助程序的第一个参数,link-to助手将用作内联形式。
语句
Click here for {{#link-to 'link1'}}more{{/link-to}}, info of {{link-to 'link text' 'link2'}}.
例子
<!DOCTYPE html> <html> <head> <title>Emberjs Template Inline Helper</title> <!-- CDN's --> <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.10.0/ember.min.js"></script> <script src="https://builds.emberjs.com/tags/v1.10.0-beta.3/ember-template-compiler.js"></script> <script src="https://builds.emberjs.com/release/ember.debug.js"></script> <script src="https://builds.emberjs.com/beta/ember-data.js"></script> </head> <body> <script type="text/x-handlebars"> Click for the {{#link-to 'info'}}Fruits{{/link-to}} information, for the documentation {{link-to 'Click for records' 'records'}}. {{outlet}} </script> <script type="text/x-handlebars" data-template-name="info"> <p>Some Fruits</p> <ul> <li>Orange</li> <li>Banana</li> </ul> </script> <script type="text/x-handlebars" data-template-name="records"> <p>Some Records</p> <ul> <li>Orange.doc</li> <li>Banana.doc</li> </ul> </script> <script type="text/javascript"> App = Ember.Application.create(); //mapping the router for different template App.Router.map(function() { //link to the info resource this.resource('info'); //link to the records resource this.resource('records'); }); </script> </body> </html>
输出
让我们执行以下步骤,看看上面的代码如何工作:
将上面的代码保存在temp_link_inline_helper.html文件中
在浏览器中打开此HTML文件。