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

template includes #73

Closed
conarwelsh opened this issue Apr 12, 2013 · 3 comments
Closed

template includes #73

conarwelsh opened this issue Apr 12, 2013 · 3 comments

Comments

@conarwelsh
Copy link

the PHP implementation does not allow relative includes, yet I cannot seem to get the JS version to do anything but relative includes. If I am rendering a template that is in a sub-folder, and it is trying to include a template that is in a sub-folder at the same level, how would I go about this.

Is there someway I could avoid it running the relativePath function, and instead check if it starts with a '/' making it an absolute path?

@justjohn
Copy link
Collaborator

The node side of twig.js (path) already has an implementation for this, where you can pass a 'base' option to twig.js, I'll update the browser side (url) to also check for the 'base' option and include relative to that if it's present.

@justjohn
Copy link
Collaborator

justjohn commented May 7, 2013

You can now set a 'base' path when rendering a template from a browser like this:

templates/
    a/
        child.twig
    b/
        parent.twig

templates/a/child.twig

{% extends "b/parent.twig" %}

...

This will correctly pull in the parent template from templates/b/parent.twig:

twig({
    base: 'templates',
    href: 'templates/a/child.twig',

    load: function(template) {
        var output = template.render();
    }
});

This change will be in the 0.6 tagged release, which I'll get up tomorrow.

@evgenius
Copy link
Collaborator

Looks like it was fixed in 0.6.

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