簡體   English   中英

xsl:帶有條件和把手的屬性

[英]xsl:attribute with condition and handlebars

我嘗試使用車把設置xsl:attribute。 代碼是:

<input type="text">
  {{#if_eq line_type 0}}
    <xsl:attribute name="disabled">true</xsl:attribute>
  {{/if_eq}}
</input>

但是這樣的構造是行不通的。 有解決問題的辦法嗎?

因此,您需要添加如下內容:

JavaScript:

    Handlebars.registerHelper('equal', function(lvalue, rvalue, options) {
        if (arguments.length < 3)
            throw new Error("Handlebars Helper equal needs 2 parameters");

        if( lvalue!=rvalue ) {
            return options.inverse(this);
        } else {
            return options.fn(this);
        }
    });

在HTML模板中,例如:

<input type="text">
  {{#equal line_type 0}}
    <xsl:attribute name="disabled">true</xsl:attribute>
  {{/equal}}
</input>

希望會有所幫助。

編輯:

{{#equal line_type 0}}    
<input type="text">
        <xsl:attribute name="disabled">true</xsl:attribute>

    </input>
{{/equal}}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM