Is there any way to create HTML markup in YUI like:
<div id={DivId}>
<p class={pClass}>
<span class={spanClass}> {Content} </span>
</p>
</div>
Is there any way to create HTML markup in YUI like:
<div id={DivId}>
<p class={pClass}>
<span class={spanClass}> {Content} </span>
</p>
</div>
I don't think so. At least not exactly. The more JavaScript like way is by manipulating the DOM elements. For example:
<body>
<div id="my-div">
<p id="my-p">
<span id="my-span></span>
</p>
</div>
<script>
YUI().use('node', function(Y) {
Y.one("#my-div").set("id", "my-new-div-id");
Y.one("#my-p").addClass("a-paragraph-class");
var mySpan = Y.one("#my-span");
mySpan.addClass("a-span-class");
mySpan.set("innerHTML","My span content.");
});
</script>
Of course this is a bit of overkill for your application. However there's a lot more you can do with YUI3 nodes than this.
John
If I understand your question correctly, Y.substitute
might be worth looking at.
If you haven't seen it, I'd recommend watching through the YUI 3 Sugar video at the YUI theater. Jump to 22:27 for more on Y.substitute
.