简体   繁体   English

ISML 到 lit-html

[英]ISML to lit-html

I'm having difficulties with rewriting ISML-Templates to lit-html.我在将 ISML 模板重写为 lit-html 时遇到了困难。

eg例如

<isset name="Variable" value="${pdict.variable}" scope="page" />

How does the isml tag <isset> work for lit-html? isml 标签<isset>如何为 lit-html 工作?

Lit-html speaks regular HTML. Lit-html 使用常规的 HTML。 You can define any custom element you want, but <isset> is neither a standard nor a custom element.您可以定义任何您想要的自定义元素,但<isset>既不是标准元素也不是自定义元素。 Meaning, <isset> element doesn't work with lit-html per-se , rather, lit-html takes your template and updates the DOM efficiently with it.意思是, <isset>元素不适用于 lit-html per-se ,而是 lit-html 获取您的模板并使用它有效地更新 DOM。 If you have some other code on the page which is parsing the rendered <isset> elements, that's fine, you can use lit-html to render them.如果页面上有其他代码正在解析渲染的<isset>元素,那很好,您可以使用 lit-html 来渲染它们。

lit-html will render nodes as you write them, although it will transform that self-closing tag to a normal tag. lit-html 将在您编写节点时呈现节点,尽管它会将自闭合标签转换为普通标签。

 (async function() { const { render, html } = await import("https://unpkg.com/lit?module"); function issets(items) { return items.map(({ name, value }) => html`<isset name="${name}" value="${value}"/>`); } render(issets([ { name: 'a', value: 1 }, { name: 'b', value: 2 } ]), document.querySelector('output')); console.log(document.querySelector('output').innerHTML) })();
 <output></output>

Rendered output:渲染 output:

<!----><!----><isset name="a" value="1"></isset><!----><!----><isset name="b" value="2"></isset><!---->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM