Coder Social home page Coder Social logo

Comments (7)

antoniogamiz avatar antoniogamiz commented on August 28, 2024 1

Mm, after taking a look at the code it looks like that literals are indeed cached.

from raku-template-mustache.

antoniogamiz avatar antoniogamiz commented on August 28, 2024 1

I think after these changes (Raku/Documentable#117) it will be enough :-). As always, thanks for your help!

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Thank you very much for opening this issue.

I've pushed some changes in version 1.2.0 which may help, caching parsed templates which were not being cached before. If you are re-using the same template files over and over (as I suspect you are), this should be much faster now. Just make sure that you keep a single Template::Mustache instance, as the cache is stored as a member and not shared between instances.

my $stache = Template::Mustache.new: from<path/to/templates>;

for @documentables -> $doc {
    # This will look up the 'document.mustache' template in the cache, and
    # any of the templates it references
    $stache.render: '{{< document }}', { 'title' => $doc.title, 'body' => $doc.body };
}

That being said, I am sure the Grammar for Template::Mustache is not efficient. It probably backtracks a lot more than it should. I have some ideas on fixing that, but haven't gotten to them. Hopefully the caching will be sufficient for your needs now. Please let me know how it goes!

Tim

from raku-template-mustache.

antoniogamiz avatar antoniogamiz commented on August 28, 2024

Where could I see those changes? I don't see new commits in this repo. Thanks for the fast reply!

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Yes, it is here on this repo (now renamed to raku-Template-Mustache on Github). They were committed a few days ago now: 4811aad

The 1.2.0 release on CPAN has it (current version is 1.2.1, with some logging features refactored).

from raku-template-mustache.

antoniogamiz avatar antoniogamiz commented on August 28, 2024

Oh here is why I have not seen the speed changes:

https://github.com/Raku/Pod-To-HTML/blob/00d1130391a38d5a0b1b13a15738bfa889726c54/lib/Pod/To/HTML.pm#L273-L280
(preview code is not working for some reason)
I suppose literals are not being cached, or cannot be cached?

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Thank you, Antonio.

Yes, explicitly marked :literals were already being cached, after finanalyst added caching. Recent changes expanded caching to all templates, literals and non-literals alike. The :literal hack you pointed to is no longer needed (we can just point :from at the templates directory and let Template::Mustache find the partials); but having it in there won't slow things down noticeably, I guess.

I'm curious what the speed difference is with the updated to Pod-To-HTML. I honestly haven't put much effort into benchmarking and optimizing. I would like to do that eventually, but have other things that are a higher priority. If the speed with caching is still a major hurdle for you, I can change my priorities.

from raku-template-mustache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.