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

Implement block() function #88

Closed
realcnbs opened this issue Mar 26, 2014 · 7 comments
Closed

Implement block() function #88

realcnbs opened this issue Mar 26, 2014 · 7 comments

Comments

@realcnbs
Copy link

This one IMO is very important to have, allows a lot of flexibility for re-usability and composition of templates. Used a lot in symfony forms twig extension here which I am considering to port (at least partially) to jtwig as independent module.

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

I didn't look into code yet for particularly this one, but it feels like it should be some kind of functionality which would insert duplicates into the render objects tree.

@joao-de-melo
Copy link
Member

In terms of architecture, this feature will require functions to have access to the rendering context.

This possible by changing the function api.

I had a tech task in mind which could be picked up here.

Basically I would like to make functions more developer friendly. That is possible if we use reflection strategies like spring to run functions. By doing so we simplify all function implementations (removing the initial requires validation) by havinf Java defined arguments.

Then, for this story we just need to have a function which will receive this special argument, the rendering context.

@realcnbs
Copy link
Author

Yeah, functions API should be refactored for sure, because similar kind of functionality we will need in the parent() function.
Not sure what exact strategies you mean but it would be really great to have functions to be type safe. That makes me think that we will need multiple function methods for every variation like: range(1,10) and range(1,10,2)
Also functions will have to know their position in the rendered object tree as well as source file information (line, position, etc).
Could you point me to the strategies you mentioned?

@joao-de-melo
Copy link
Member

I'm doing some work on it. But I'm talking about this: http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-typeconversion

joao-de-melo pushed a commit to joao-de-melo/jtwig that referenced this issue Apr 8, 2014
@thomas-p-wilson
Copy link

I was moving toward implementation on this one, but realized that as the jtwig-functions module is separate from the jtwig-core module, @JtwigFunctions cannot have access to the RenderContext in a typesafe manner. To add jtwig-core as a dependency of jtwig-functions would introduce a circular reference in the Reactor build. I see two options then: 1) produce a contract module which retains those elements common to both, or 2) fold jtwig-functions into jtwig-core. Thoughts?

@joao-de-melo
Copy link
Member

Try creating the function in the jtwig-core itself. That's what I was thinking about.

@thomas-p-wilson
Copy link

Okay, I should be able to do that!
On Oct 19, 2014 7:11 AM, "João Melo" notifications@github.com wrote:

Try creating the function in the jtwig-core itself. That's what I was
thinking about.


Reply to this email directly or view it on GitHub
https://github.com/lyncode/jtwig/issues/88#issuecomment-59646472.

@thomas-p-wilson
Copy link

The block() function was implemented in PR #263. Closing.

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

3 participants