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

Feature request: Compiled templates support #28

Open
natehitze opened this issue Nov 5, 2020 · 4 comments
Open

Feature request: Compiled templates support #28

natehitze opened this issue Nov 5, 2020 · 4 comments

Comments

@natehitze
Copy link

It would be awesome if this worked with compiled templates. Is that even possible with how Stubble.Compilation works now? I tried changing some of the classes to use the Stubble.Compilation classes but quickly realized that that won't work at all since Stubble.Compilation renderers work differently than the standard renderers (...duh).

Side note - it might be helpful to put a note in the docs about how helpers don't work with compiled templates currently.

@Romanx
Copy link
Contributor

Romanx commented Nov 8, 2020

Hi there,

It's theoretically possible for the helpers to work with the compilation renderer however if it's in the same form as it currently is or in a reduced form of only allowing things that can be condensed into expression trees.

Let us have a think and a demo and we can see what works. If you've got an idea of what kind of templates and helpers you'd want to use that would be useful.

@natehitze
Copy link
Author

What initially brought me to this was the exact example in the docs: converting a decimal to a currency string.

It would be cool to be able to return a template that would get rendered itself (in its own context). For instance I have some common event information that I want to include in multiple templates. Each template's model has a shared EventInfo property and I copy the formatting for that property from one template to another. That being said, as long as I can input an object and output a string (or multiple strings if there's some sort of StringBuilder underneath) I could just do the template formatting in the helper itself.

@Romanx
Copy link
Contributor

Romanx commented Nov 10, 2020

Yeah that kind of use case makes perfect sense, especially for sharing between templates. I'd usually advocate for transforming before your templating as suggested by the Mustache spec for removing logic from your templates but i'm aware this isn't always possible or practical 👍

@natehitze
Copy link
Author

I created a proof of concept here: https://github.com/natehitze/Stubble.Helpers/tree/add-compiled-helpers

Any thoughts on that?

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