Mustache Template usage in Dart

二次信任 提交于 2019-12-24 04:13:08

问题


Fairly recent to web programming and all apologies for asking a basic question.

In the test.dart file, a template is created and populated as below

import 'dart:html';
// IMPORT MUSTACHE FOR TEMPLATES
import 'package:mustache/mustache.dart' as mustache;

function loadData()
{
 // some script .....
  output = template.renderString({
 'data_cell': [
     {'event_title': TitleOne,'event_desc' : Desc},]});
 }

In the test.html file, how can I insert the "output" in the below "data_cell" div.

<body>
<p id="text">Application</p>
<div class="row">
   <div class="data_cell">
        <!-- HOW TO INSERT "output" generated from DART script here" -->
   </div>
</body>

回答1:


querySelector('div.data_cell').appendHtml(output);

or

var nodeValidator = new NodeValidatorBuilder()
    ..allowHtml5()                            // according to your requirements
    ..allowElement('a', attributes: ['href']) // - " -
    ..allowElement('img', attributes: ['src']); // - " -
querySelector('div.data_cell').append(new Element.html(output, validator: nodeValidator);


来源:https://stackoverflow.com/questions/23767566/mustache-template-usage-in-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!