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

partial include from sub directories #83

Closed
madsleejensen opened this issue Jul 14, 2014 · 4 comments
Closed

partial include from sub directories #83

madsleejensen opened this issue Jul 14, 2014 · 4 comments
Labels

Comments

@madsleejensen
Copy link

currently (version 0.14) im unable to specify partials in sub directories to a basedir

ex: {{>my_sub_directory/test}}

it will only work if i add "my_sub_directory/" to basedir configuration. Im quite sure it worked before but around two weeks ago i stopped, i can see some changes has been made to

13ba7d4

case '>':
            self::readPartial($vars[0][0], $context);
 return true;

a quick workaround i did was to replace it with

case '>':
            self::readPartial(implode(DIRECTORY_SEPARATOR, $vars[0]), $context);
 return true;

the problem might actually be that the parser does not see "my_sub_directory/test" as one string so in $vars the string is split up into an array with 2 elements split by "/"

@madsleejensen
Copy link
Author

The workaround didnt quite work :) but i rolled back to commit 8797485 where it seems to work.

@zordius
Copy link
Owner

zordius commented Jul 14, 2014

Hello all, after tests on handlebars.js I found some interesting things:

  1. {{ > foo }} works just like {{ > "foo" }} or {{ > [foo] }}.
  2. {{ > foo/bar }} works just like {{ > "foo/bar" }} or {{ > [foo/bar] }} .
  3. {{> foo }} is special case of mustache/handlebars , foo is treated as "foo" , not a variable
  4. {{> foo bar}} works just like {{>"foo" bar}} , here bar is variable and do context change for the partial.

So, 1st param of > is special case , we should not touch it.

@zordius
Copy link
Owner

zordius commented Jul 14, 2014

Now {{> foo/bar }} should be correct , please try current master, thanks.

( But , {{> [foo/bar] }} and {{> "foo/bar" }} is buggy now , I guess no one use these 2 cases so I just ignore them. )

@madsleejensen
Copy link
Author

Works great thanks for the fast fix :)

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

No branches or pull requests

2 participants