本文整理汇总了TypeScript中@mask-j/jMask.jMask函数的典型用法代码示例。如果您正苦于以下问题:TypeScript jMask函数的具体用法?TypeScript jMask怎么用?TypeScript jMask使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jMask函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mask_optimize
mask_optimize(frag, assert.await(function(frag){
var baz = jMask(frag).filter('baz');
eq_(baz.length, 0);
txt = jMask(frag).filter('span').text();
eq_(txt, 'Baz');
done();
}));
示例2: parser_parse
.forEach(data => {
var {template, expect} = data;
var nodes = parser_parse(template);
var node = jMask(nodes).find('import').get(0);
is_(node, 'Object');
expect(node);
var str = mask_stringify(node);
eq_(template, str);
})
示例3: function
$getNode: function (id, filter) {
var ctx = this, node;
while (ctx != null) {
node = ctx[id];
if (node != null)
break;
ctx = ctx.parent;
}
if (filter != null && node != null) {
node = {
nodes: jMask(node.nodes).filter(filter)
};
}
return node;
}
示例4: function
.done(function(str) {
// remove all remote styles
var ast = mask_TreeWalker.walk(str, function(node){
if (node.tagName === 'link' && node.attr.href) {
return { remove: true };
}
});
ast = jMask('module')
.attr('path', path)
.append(ast);
var str = mask_stringify(ast[0], {
indent: opts.minify ? 0 : 4
});
resolve(str);
});
示例5: function
render: function(model, ctx, container) {
this.html = jMask(this.nodes).text(model, ctx, this);
if (container.insertAdjacentHTML) {
container.insertAdjacentHTML('beforeend', this.html);
return;
}
if (container.ownerDocument) {
var div = document.createElement('div'),
child;
div.innerHTML = this.html;
child = div.firstChild;
while (child != null) {
container.appendChild(child);
child = child.nextSibling;
}
}
},
示例6: function
progress_: function(ctx, container){
var nodes = this.progressNodes;
if (nodes == null) {
return;
}
var hasLiteral = nodes.some(function(x){
return x.type === Dom.TEXTNODE;
});
if (hasLiteral) {
nodes = jMask('div').append(nodes);
}
var node = {
type: Dom.COMPONENT,
nodes: nodes,
controller: new Component,
attr: {},
};
builder_build(node, null, ctx, container, this);
},
示例7: parser_parse
].forEach(x => {
var nodes = parser_parse('div { ' + x.template + '}'),
$nodes = jMask(nodes),
$vars = $nodes.find('var');
eq_($vars.length, x.varNames.length);
$vars.each(($var, i) => {
var key = x.varNames[i];
$var = $var.attr[key];
is_($var, 'String');
deepEq_(
expression_eval($var),
x.expect[key]
);
})
});
示例8: function
constructor: function(node, model, ctx, el, ctr){
var content = node.content;
if (content == null && node.nodes) {
var x = node.nodes[0];
if (x.type === Dom.TEXTNODE) {
content = x.content;
} else {
content = jMask(x.nodes).text(model, ctr);
}
}
this.id = node.id;
this.body = is_Function(content)
? content('node', model, ctx, el, ctr)
: content
;
if (this.tagName === 'style') {
this.body = css_ensureScopedStyles(this.body, node, el);
}
}
示例9: function
resolve: function(node, id){
var nodes = cache_[id];
if (nodes != null)
return nodes;
var selector = ':template[id=' + id +']',
parent = node.parent,
tmpl = null
;
while (parent != null) {
tmpl = jMask(parent.nodes)
.filter(selector)
.get(0);
if (tmpl != null)
return tmpl.nodes;
parent = parent.parent;
}
log_warn('Template was not found', id);
return null;
},
示例10: UTest
import { parser_parse } from '@core/parser/exports';
import { jMask } from '@mask-j/jMask';
UTest({
'content':{
'block' () {
var template = `script {"A"}`;
var node = parser_parse(template);
eq_(node.content, '"A"');
},
'nodes' () {
var template = `script > :html {"A"}`;
var node = parser_parse(template);
eq_(node.nodes[0].tagName, ':html');
var txt = jMask(node).text();
eq_(txt, 'A');
},
},
'attribute' : {
'block' () {
var template = `script type='text/mask' {"A"}`;
var node = parser_parse(template);
eq_(node.content, '"A"');
eq_(node.attr.type, 'text/mask');
},
'literal' () {
var template = `script type='text/mask' > '<A>'baz`;
var nodes = parser_parse(template).nodes;
eq_(nodes[0].content, '<A>');
eq_(nodes[0].attr.type, 'text/mask');