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

Partials with relative path not implemented #91

Closed
nateware opened this issue Apr 20, 2011 · 3 comments
Closed

Partials with relative path not implemented #91

nateware opened this issue Apr 20, 2011 · 3 comments

Comments

@nateware
Copy link

Hi,

I am willing to supply a patch for this, but got a bit lost in the source, to be honest.

In the canonical Ruby mustache.rb, partials with relative paths are supported. For example:

<!-- test.mustache -->
<h1>{{test}}</h1>
{{>relpath/test2}} 

This will look in the subdir relpath/ and open the file test2.mustache.

However, in mustache.js, this does not work. In fact, the tag isn't even parsed and is output verbatim as:

<h1>Hi there</h1>
{{>relpath/test2}} 

The issue appears to be this regex:

  var new_regex = function() {
    return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
      that.ctag + "+", "g");
  };

Notice how it has this:

[^\\/#\\^]+?

Removing the "/" from that regex should work. Thoughts?

Also, where do I get the "js" command line program? I tried to run the spec and then googled, found V8 and Spidermonkey, but neither seems to spit out a "js" command.

Thanks,
Nate

@nateware
Copy link
Author

I got spidermonkey to compile and am running the specs. Removing the "/" works.

I'm trying to add a subdir spec but am having to modify mustache_spec.rb - will send a pull request when fixed.

@janl
Copy link
Owner

janl commented Apr 20, 2011

a patch and tests would be great, thanks Nate :)

@nateware
Copy link
Author

Pull request sent: #92

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