本文整理汇总了TypeScript中@core/parser/exports.parser_parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parser_parse函数的具体用法?TypeScript parser_parse怎么用?TypeScript parser_parse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parser_parse函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mask_merge
export function mask_merge(a, b, owner?, opts?, stats?) {
if (typeof a === 'string') {
a = parser_parse(a);
}
if (typeof b === 'string') {
b = parser_parse(b);
}
if (a == null || (is_ArrayLike(a) && a.length === 0)) {
return b;
}
var placeholders = _resolvePlaceholders(b, b, new Placeholders(null, b, opts));
var out = _merge(a, placeholders, owner);
if (stats != null) {
stats.placeholders = placeholders;
}
var extra = placeholders.$extra;
if (extra != null && extra.length !== 0) {
if (is_Array(out)) {
return out.concat(extra);
}
return [out].concat(extra);
}
return out;
};
示例2: attributes
'right attributes (quoteless)': function(){
var attr = parser_parse("div width=10 height=20 id=30 key otherkey p = tryam;").attr;
eq_(attr.width, '10');
eq_(attr.height, '20');
eq_(attr.id, '30');
eq_(attr.key, 'key');
eq_(attr.otherkey, 'otherkey');
eq_(attr.p, 'tryam');
var attr = parser_parse("div dr = drrrr sh = shrrrr").attr;
eq_(attr.dr, 'drrrr');
eq_(attr.sh, 'shrrrr');
},
示例3: parse
function parse(template) {
var imports = parser_parse(template),
import_ = imports.nodes[0];
is_(import_, 'Object', `Not correct parsed ${template}`);
return import_;
}
示例4: getTemplateProp_
function getTemplateProp_(compo) {
var template = compo.template;
if (template == null) {
var attr = compo.attr;
if (attr == null) return null;
template = attr.template;
if (template == null) return null;
delete compo.attr.template;
}
if (typeof template === 'object') return template;
if (is_String(template)) {
if (template.charCodeAt(0) === 35 && /^#[\w\d_-]+$/.test(template)) {
// #
var node = document.getElementById(template.substring(1));
if (node == null) {
log_warn('Template not found by id:', template);
return null;
}
template = node.innerHTML;
}
return parser_parse(template);
}
log_warn('Invalid template', typeof template);
return null;
}
示例5: parser_parse
.forEach(data => {
var {template} = data;
debugger;
var nodes = parser_parse(template);
var str = mask_stringify(nodes);
eq_(str, template);
})
示例6: function
'interpolation': function(){
var node = parser_parse(`
foo ~[bar]
`)
var error = errors.pop();
has_(error.message, 'Invalid interpolation (in attr name)');
},
示例7: testSingle
function testSingle(template, fn) {
var nodes;
for (var i = 0, x, length = template.length; i < length; i++) {
fn(parser_parse(template[i]), i);
}
}
示例8: function
'has literal': function() {
var node = parser_parse("someCusomTag { span; } customTag; span; someCusomTag{} div > 'mycontent'");
node = getProperty(node, 'nodes.4');
assert(node.tagName == 'div', 'literals container is not "div"');
assert(getProperty(node, 'nodes.0.content') == 'mycontent', "Literal failed");
},