问题
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