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

Multi-document YAML files are not processed correctly #254

Open
gaborkr opened this issue Aug 1, 2019 · 2 comments
Open

Multi-document YAML files are not processed correctly #254

gaborkr opened this issue Aug 1, 2019 · 2 comments

Comments

@gaborkr
Copy link

gaborkr commented Aug 1, 2019

$ uname -srio
Linux 4.18.0-25-generic x86_64 GNU/Linux
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
$ apt show ruby-mustache
Package: ruby-mustache
Version: 1.0.2-1
(...)
$ mustache -v
Mustache v1.0.2
$ cat name.yaml
---
name: 1
---
name: 2
---
name: 3
---
$ cat name.template
Hello {{name}}!
$ mustache -t name.yaml name.template  
[:multi,
 [:static,
  "---\n" +
  "name: 1\n" +
  "---\n" +
  "name: 2\n" +
  "---\n" +
  "name: 3\n" +
  "---\n"]]
$ mustache name.yaml name.template
Hello 3!

Expected output:

Hello 1!
Hello 2!
Hello 3!

ps. Mustache v1.1.0 behaves in the same way.

(Might be unrelated:)

$ cat name.yaml name.template |mustache
Traceback (most recent call last):
        4: from /usr/bin/mustache:97:in `<main>'
        3: from /usr/bin/mustache:84:in `process_files'
        2: from /usr/bin/mustache:84:in `reduce'
        1: from /usr/bin/mustache:84:in `each'
/usr/bin/mustache:84:in `merge': no implicit conversion of String into Hash (TypeError)

or

$ cat name.yaml name.template |mustache
Traceback (most recent call last):
        6: from /usr/local/bin/mustache:23:in `<main>'
        5: from /usr/local/bin/mustache:23:in `load'
        4: from /var/lib/gems/2.5.0/gems/mustache-1.1.0/bin/mustache:102:in `<top (required)>'
        3: from /var/lib/gems/2.5.0/gems/mustache-1.1.0/bin/mustache:89:in `process_files'
        2: from /var/lib/gems/2.5.0/gems/mustache-1.1.0/bin/mustache:89:in `reduce'
        1: from /var/lib/gems/2.5.0/gems/mustache-1.1.0/bin/mustache:89:in `each'
/var/lib/gems/2.5.0/gems/mustache-1.1.0/bin/mustache:89:in `merge': no implicit conversion of String into Hash (TypeError)
@gaborkr
Copy link
Author

gaborkr commented Aug 1, 2019

I'm not sure what this line is supposed to do (what are we "merging" and why?):

puts Mustache.render template, yaml.compact.reduce(&:merge)

but it certainly makes no sense to me.
Replace

        puts Mustache.render template, yaml.compact.reduce(&:merge)

with

	yaml.compact.each { |item| 
	        puts Mustache.render template, item
	}

and it works as expected.

@Kixunil
Copy link

Kixunil commented Apr 20, 2020

Is this project even active? This issue was reported > half year ago with a trivial fix. Got bitten by it recently. :(

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

2 participants