kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
522 stars 60 forks source link

<a href="@item.html">... #122

Closed fghhfg closed 6 years ago

fghhfg commented 6 years ago

Code:

<div>
  @model.xxx.forEach(function(item){
    <a href="@item.html">@item</a>
  })
</div>

model.xxx = ['home', 'product', ...]

Expected:

<div>
  <a href="home.html">home</a><a href="product.html">product</a>...
</div>

What I got:

<div>
  <a href="">home</a><a href="">product</a>...
</div>

And how do make it newline?

I want my html become:

<div>
  <a href="home.html">home</a>
  <a href="product.html">product</a>
  ...
</div>

it is more readable...

kirbysayshi commented 6 years ago

The new lines should be kept, not sure why they’re not.

The expression @item.html tells vash to look for an html property on the item object. You can try either:

@(item + “.html”) @(item).html

I’m not sure the second will work. The first one with manual concatenation should though. On Fri, Oct 13, 2017 at 9:17 AM fghhfg notifications@github.com wrote:

Code:

@model.xxx.forEach(function(item){ @item })

model.xxx = ['home', 'product', ...]

Expected:

homeproduct...

What I got:

homeproduct...

And how do make it newline?

I want my html become:

home product ...

it is more readable...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kirbysayshi/vash/issues/122, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFiz5Xspt1sR98Q9K2YCFX_RousLllvks5sr2LxgaJpZM4P4eTL .

fghhfg commented 6 years ago

You are so quick!

@(item + “.html”) : this one works. @(item).html: this one doesn't work.

thank you.

kirbysayshi commented 6 years ago

Thanks for reporting back, and glad to help! On Fri, Oct 13, 2017 at 9:31 AM fghhfg notifications@github.com wrote:

You are so quick!

@(item + “.html”) : this one works. @(item).html: this one doesn't work.

thank you.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/kirbysayshi/vash/issues/122#issuecomment-336453036, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFiz7lj6is4iSZRYQCf98QFm_pInr2iks5sr2YagaJpZM4P4eTL .