开发者

YUI 3 html templating

开发者 https://www.devze.com 2023-01-22 05:43 出处:网络
Is there any way to create HTML markup in YUI like: <div id={DivId}> <p class={pClass}> <span class={spanClass}> {Content} </span>

Is there any way to create HTML markup in YUI like:

<div id={DivId}>
 <p class={pClass}>
  <span class={spanClass}> {Content} </span>
 </p>
</di开发者_如何转开发v>


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.


I did the same thing.... Here is what I used.

var resultFormatTemplate =
        '<div class="result">{first_name}, {last_name}</div>';

function resultFormat(query, results) {
    return Y.Array.map(results, function (result) {
        var rep = result.raw;

        return Y.Lang.sub(resultFormatTemplate, {
            first_name : rep['First Name'],
            last_name  : rep['Last Name']
        });
    });
};

In the Y.one tag I used resultFormatter : resultFormat to call the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消