Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Being able to know what template is being used. #151

Closed
maca opened this Issue Jun 14, 2012 · 2 comments

Comments

Projects
None yet
2 participants

maca commented Jun 14, 2012

Hi, I am trying to make a framework agnostic gem for defining view helpers and I have the need to know what templating engine is being used to tho the capturing, but since tilt evaluates the template code in the context of the object where rendering takes place I've no way of knowing what engine is being used.

sinatra/content_for solves this by defining a @current_engine variable:
https://github.com/sinatra/sinatra-contrib/blob/2d2fd504312920019bd1/lib/sinatra/content_for.rb#L52-55

But I want a generic/agnostic solution.

This issue is related to rtomayko/tilt#68 that request a tilt implementation for concat/capture.

Here's the hack I am using to access the tilt template by monkey patching Tilt::Template:

https://github.com/maca/tiny/blob/1e09a1421a609b21eb71ae2d4a5b46ccb01b411c/lib/tiny/tilt.rb

Please give consideration to this feature request, or please suggest a better workaround.
I can give it a shot too, what are the mantainers' thoughts on this?

Thanks

Collaborator

judofyr commented May 2, 2013

Hm. Maybe something like this?

def Tilt.current_template
  Thread.current[:tilt_current_template]
end

@judofyr judofyr closed this in 9472c6f May 12, 2013

Collaborator

judofyr commented May 12, 2013

I've introduced Tilt.current_template as an experimental feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment