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

Using several themes in the same process #79

Open
stof opened this issue Jun 19, 2013 · 6 comments · May be fixed by #116
Open

Using several themes in the same process #79

stof opened this issue Jun 19, 2013 · 6 comments · May be fixed by #116

Comments

@stof
Copy link
Contributor

stof commented Jun 19, 2013

Currently, it is not possible to use the same template in different themes in the same PHP process, because the Twig_Loader_Filesystem caches the resolution of template names to file names in memory.
Fixing this would require replacing the Filesystem loader with a theme-aware version (it would also be required for #50 btw).

My use case for rendering the template in different themes int he same process is background processing: I select the theme based on the user in my app. The background process sending them emails should also use the right theme. But the process can send emails to users with different themes.
Not being able to change the theme is already an issue when doing it in a command, but it becomes even worse when the logic is in a RabbitMQ consumer (as the process is long-running).

As I need it at work, I will look into implementing it.

@lsmith77
Copy link
Contributor

I guess this might also enable referencing a non themed template from the themed template with the same "name"

@stof
Copy link
Contributor Author

stof commented Jun 20, 2013

it would require defining a specific naming convention for this

@yellow1912
Copy link

Any update on this as this looks very interesting.

@xanido
Copy link

xanido commented Feb 9, 2015

I also need this functionality, and so took a quick look at implementing it.

Apologies if I have missed something, but this seems as though it can be solved relatively simply by using a custom Twig filesystem loader, as stof suggested. This solution does not solve the 'referencing a non-themed template from a themed template' issue.

Here's the proof of concept: c501b2d. Please excuse any code formatting issues - if this solution has any legs I'll tidy it up and submit a PR.

Suggestions are welcome.

@lsmith77
Copy link
Contributor

lsmith77 commented Feb 9, 2015

its always easier to review code in a PR .. so open up the PR and we can discuss. note you can update a PR by simply pushing to your branch as often as you want.

@xanido xanido linked a pull request Feb 9, 2015 that will close this issue
@xanido
Copy link

xanido commented Feb 9, 2015

Done. See #116. Cheers.

@lsmith77 lsmith77 added this to the 1.3.0 milestone May 10, 2015
@lsmith77 lsmith77 modified the milestones: 1.3.0, 1.4.0 Aug 28, 2015
@lsmith77 lsmith77 removed this from the 1.4.0 milestone Jan 4, 2018
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

Successfully merging a pull request may close this issue.

4 participants