2017-01-05 21 views
2

動的にURLテキストを変更したい。これは私が私のパグのテンプレートエンジンで使用していたコードです:Pug(Jade)テンプレート内のタグの動的URL

html 
    head 
    title=title 
    <link rel="stylesheet" type="text/css" href="/css/style.css"> 
    body(style={'background-color': color }) 
    #content 
     .bigquestion=message 
     | <div class='questionnumber'> 
     a(href=`/question/`+ questionnumber) =questionnumber 
     |/
     =totalnumberofquestions 
     | </div> 

私は次のように取得しています:

<div class='questionnumber'><a href="/question/98">question =questionnumber</a>98/ 135</div> 

私は出力がこのような何かになりたい:

<div class='questionnumber'><a href="/question/98">question 98</a>/135</div> 

PugテンプレートエンジンのURLに動的テキストを使用できる方法はありますか?

静的なテキストのみを見つけることができました。例はhereです。

答えて

3

ドキュメントのこのセクションをチェックしてください。

https://pugjs.org/language/interpolation.html

html 
    head 
    title=title 
    <link rel="stylesheet" type="text/css" href="/css/style.css"> 
    body(style={'background-color': color }) 
    #content 
     .bigquestion=message 
     | <div class='questionnumber'> 
     a(href=`/question/`+ questionnumber) #{questionnumber} 
     |/
     =totalnumberofquestions 
     | </div> 
3

あなたの変数に#{questionnumber}のように、補間を使用する必要があります。

関連する問題