Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line break #16

Closed
gvieira opened this issue Apr 6, 2015 · 4 comments
Closed

Line break #16

gvieira opened this issue Apr 6, 2015 · 4 comments

Comments

@gvieira
Copy link

gvieira commented Apr 6, 2015

Hi there,

I'm a Lua newbie and I think I'm doing something wrong.
Check my code (from lustache's README):

lustache = require "lustache"

view_model = {
  stooges = {
    { name = "Moe" },
    { name = "Larry" },
    { name = "Curly" }
  }
}

template = [[
{{#stooges}}
<b>{{name}}</b>
{{/stooges}}]]

output = lustache:render(template, view_model)

print(output)

Output:


<b>Moe</b>

<b>Larry</b>

<b>Curly</b>

My first guess was related to mustache, so I tried it in http://trymustache.com and the output was the following.

Output:

<b>Moe</b>
<b>Larry</b>
<b>Curly</b>

After, I tried doing the same using Ruby, because I know it better. Check it out:

require 'mustache'

view_model = {
  :stooges => [
    { :name => "Moe" },
    { :name => "Larry" },
    { :name => "Curly" }
  ]
}

template = <<-EOS
{{#stooges}}
<b>{{name}}</b>
{{/stooges}}
EOS

output = Mustache.render(template, view_model)

puts output

Output:

<b>Moe</b>
<b>Larry</b>
<b>Curly</b>

Am I doing something wrong with lustache?

@hookenz
Copy link

hookenz commented May 3, 2015

I noticed this too. Placing it all on a single line fixed it for me.

@gvieira
Copy link
Author

gvieira commented May 4, 2015

@hookenz Yeah, I tried that too and it worked, but this is not the default behavior of mustache.

brimworks added a commit to Distelli/lustache that referenced this issue Sep 2, 2015
@brimworks
Copy link
Contributor

This appears to fix the problem:

f08de79

...basically I translated the code from here into Lua:

https://github.com/janl/mustache.js/blob/master/mustache.js

(and there was an off-by-one error due to 1 indexing in Lua)

@gvieira
Copy link
Author

gvieira commented Sep 2, 2015

Hey @brimworks! Thanks for the follow up! Very nice. I couldn't test it, but it certainly make sense. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants