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

Question :: About performance and internal partial directory mapping #55

Closed
xerocole opened this issue Apr 18, 2018 · 4 comments
Closed

Comments

@xerocole
Copy link

xerocole commented Apr 18, 2018

Hi @yanick, first and foremost thank for the great work on this perl implementation of Mustache. I have a few questions since I am thinking of incorporating this module as the main renderer for my homegrown web framework:

  • Mustache being logic-less is quite fast by design, and my homegrown system is CGI based (well FCGI) so I am trying to keep the modules and logic very lean for performance reasons. Would you say this module will work well in that environment ( low overhead since my sites have a lot of traffic )?
  • Is it safe to assume that if we choose a file (direct file) in the templates, that your module will set internally it's partials path to the parent folder of the direct file?

Many thanks again and again great work!

@yanick
Copy link
Owner

yanick commented Apr 19, 2018

Hi @xerocole !

Thanks for the kind words. :-) Now, let's see if I can answer your questions.

  1. It should play well with that kind of env, I think. The work involved with the template is two-fold: the compilation of the Mustache code into Perl code, and the rendering of the template itself. The key would be to have a persistent state such that you compile the template once and re-use it over and over again instead of re-compiling the whole thing every time.

  2. Yes! https://github.com/yanick/Template-Mustache/blob/releases/lib/Template/Mustache.pm#L38

@xerocole
Copy link
Author

@yanick , that is great news and again great work! Thank you for responding.

One small other question (maybe a good tip and trick item): Do you know if it is possible to pull the parsed (template) not rendered template, with all the partials interpolated from this class in string?

The reason I ask is because I need to do some validation of the template ( as a whole ) per request before we render.

Thoughts?

@yanick
Copy link
Owner

yanick commented Apr 20, 2018

Do you know if it is possible to pull the parsed (template) not rendered template, with all the partials interpolated from this class in string?

I don't think so. The partials are not interpolated when the template is parsed, but called during the rendering. What you can do, however, is look at the partials object themselves

say for map {  $_->template } values %{ $main_template->partials };

it's not exactly the same, but maybe it still can satisfy your needs?

@yanick
Copy link
Owner

yanick commented Jun 14, 2018

I assume that answered the question. I'll close the ticket, but if you have any question, don't hesitate to open it again.

@yanick yanick closed this as completed Jun 14, 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

No branches or pull requests

2 participants