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

support include function #392

Open
olets opened this issue Jun 29, 2016 · 20 comments
Open

support include function #392

olets opened this issue Jun 29, 2016 · 20 comments

Comments

@olets
Copy link
Member

olets commented Jun 29, 2016

The include() functions is equivalent to the include tag. It breaks twig.js with "Cannot call method 'replace' of undefined."

Example:
{{ include('template.html', {foo: 'bar'}, with_context = false) }}
{% include 'template.html' with {'foo': 'bar'} only %}

http://twig.sensiolabs.org/doc/functions/include.html

edit following #392 (comment): I don't recall why this was closed. reopening

@olets olets changed the title support include function (and any other semi-documented features that might be out there) support include function (there may be other semi-documented new features out there too) Jun 29, 2016
@olets olets changed the title support include function (there may be other semi-documented new features out there too) support include function Jun 29, 2016
@olets olets closed this as completed Jun 29, 2016
@hawkeyetwolf
Copy link

hawkeyetwolf commented Apr 4, 2017

@olets, it does? What am I missing? I get:

TwigException: include function does not exist and is not defined in the context

@JohnAlbin
Copy link
Contributor

I've added this to the implementation notes on the wiki. https://github.com/twigjs/twig.js/wiki/Implementation-Notes

@Bilge
Copy link

Bilge commented Jun 22, 2021

Why was this closed? The include function is the recommended method of inclusion, according to the docs:

Note: It is recommended to use the include function instead as it provides the same features with a bit more flexibility

If this is still not supported, it should be reopened.

@MothannaDoubaa
Copy link

Hello , any update here ?

@willrowe
Copy link
Collaborator

willrowe commented Jun 2, 2023

If someone is able to provide a TwigFiddle example that works and an example using this template that does not work, then I can look into it more.

@bronzehedwick
Copy link

bronzehedwick commented Aug 8, 2023

Hey @willrowe

Here's the TwigFiddle showing the include() working as expected.

Here's the TwigJS version erroring out.

From the console:

TwigException: include function does not exist and is not defined in the context

@Geolim4
Copy link
Contributor

Geolim4 commented Oct 6, 2023

Simple question: how can I use the include() function when the main template as been rendered from a string:

https://github.com/Geolim4/In-Memoriam/blob/60412b8730f68ecf2005c3694e41fdbb73254927/src/ts/Extensions/renderer.ts#L92

Should include() get implemented as a callback function on my own when Twig render is called on a string instead of a filename ?

@willrowe
Copy link
Collaborator

@Geolim4 you can't use the include function because it is not currently supported. This issue is for adding support for it.

@Geolim4
Copy link
Contributor

Geolim4 commented Oct 11, 2023

@Geolim4 you can't use the include function because it is not currently supported. This issue is for adding support for it.

Ohhh okay, so the readme is a bit lying then -_-

@willrowe
Copy link
Collaborator

the readme is a bit lying then

What do you mean?

@Geolim4
Copy link
Contributor

Geolim4 commented Oct 11, 2023

The implementation note says that "include" is supported while its not actually :(

https://github.com/twigjs/twig.js/wiki/Implementation-Notes

@willrowe
Copy link
Collaborator

I've added this to the implementation notes on the wiki. https://github.com/twigjs/twig.js/wiki/Implementation-Notes

@JohnAlbin did you update the implementation notes when you were under the impression that support had been added?

@JohnAlbin
Copy link
Contributor

@willrowe I think you are misreading the docs. The include tag is listed as supported. I added the note about the include function that says:

include: Throws error: "include function does not exist and is not defined in the context" #392

@willrowe
Copy link
Collaborator

willrowe commented Oct 11, 2023

@JohnAlbin great, thanks for the clarification.

@Geolim4 the implementation notes are correct. It says that the include tag is supported and the include function is not.

@Geolim4

This comment was marked as off-topic.

@willrowe
Copy link
Collaborator

@Geolim4 this issue is for adding support for the include function, not for general troubleshooting.

@Geolim4
Copy link
Contributor

Geolim4 commented Oct 11, 2023

@Geolim4 this issue is for adding support for the include function, not for general troubleshooting.

Still, the include tag is either unclear or not enough documented, so I think its indirectly related ?

@willrowe
Copy link
Collaborator

@Geolim4 this issue is a feature request. Please search through the existing issues and documentation. If there is nothing in there related to what you want to do then open a new issue.

@Dru-S
Copy link

Dru-S commented Feb 19, 2024

Hi @willrowe, are there any update on this include function implementation?

@willrowe
Copy link
Collaborator

@Dru-S I have not had a chance to work on this yet, but if you want to submit a PR I will review it.

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

No branches or pull requests

9 participants