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

Specify template root path #192

Open
jasonm opened this issue Jul 21, 2011 · 3 comments
Open

Specify template root path #192

jasonm opened this issue Jul 21, 2011 · 3 comments

Comments

@jasonm
Copy link
Contributor

jasonm commented Jul 21, 2011

When using Jammit, we run into a slightly sticky issue as an app grows from one template subdirectory to multiple template subdirectories.

Let's say you place templates in app/templates. You work for a while on the "Tasks" feature, placing templates under app/templates/tasks. So, window.JST looks something like:

JST['form']
JST['show']
JST['index']

Now, you add another directory under app/templates, say app/templates/user. Now, all JST references are prefixed with their parent directory name so they are unambiguous:

JST['tasks/form']
JST['tasks/show']
JST['tasks/index']
JST['users/new']
JST['users/show']
JST['users/index']

This breaks existing JST references. We've worked around this in new apps by monkeypatching the jammit base template path to a fixed parent directory from the get-go:

Jammit::Compressor.class_eval do
  private
  def find_base_path(path)
    File.expand_path(Rails.root.join('app','templates'))
  end
end

What do you think of either allowing a configurable option? Say, an assets.yml entry template_base_path which, if present, is always used as the template base path. In the absence of this option, the current logic would be preserved.

@shakerlxxv
Copy link

+1 for the configurable option.

@jasonm
Copy link
Contributor Author

jasonm commented Aug 19, 2011

Thoughts from the authors? Would you accept a pull request adding the configurable option?

@jashkenas
Copy link
Member

Sounds good to me.

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