【问题标题】:Mustache Template usage in DartDart 中的 Mustache 模板用法
【发布时间】:2014-07-09 04:09:54
【问题描述】:

刚接触网络编程,很抱歉提出一个基本问题。

在 test.dart 文件中,创建并填充了一个模板,如下所示

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},]});
 }

在 test.html 文件中,如何在下面的“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>

【问题讨论】:

    标签: templates dart dart-html


    【解决方案1】:
    querySelector('div.data_cell').appendHtml(output);
    

    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);
    

    【讨论】:

    • 非常感谢!有效!!
    • 如果答案解决了您的问题,您可以通过单击向上/向下投票按钮下方的复选标记来接受它。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多