Multiple directories #2

Merged
merged 4 commits into from Aug 25, 2012

2 participants

@conrad-vanl

Not sure if this is best way to handle this, but I needed sinatra-ember to accomplish two things that it wasn't: traverse multiple directories (was throwing errors), and add those directories to the template name so that template names across directories don't have to be unique.

My approach changes the api slightly.

Usage:
register Sinatra::Ember
ember {

templates '/templates.js', ['app/templates']

}

Where ['app/templates'] will require the entire tree within the templates/ directory.

If this is the tree:

  • app
    • templates
      • posts
      • view.handlebars
    • users
      • view.handlebars
      • delete.handlebars

Then the corresponding template names will be:
posts/view
users/view
users/delete

Oh, and I also added support for using .handlebars, .hjs, or .hbs extensions for templates, as there doesn't seem to be a standard.

Conrad VanLa... added some commits Aug 25, 2012
Conrad VanLandingham added multi-directory support
Usage:
register Sinatra::Ember
ember {

templates '/templates.js', ['app/templates']

}

will include all templates inside (recursively) app/templates
6a15c7d
Conrad VanLandingham fixed typo 87cf82d
Conrad VanLandingham moved some things around 0304be2
Conrad VanLandingham finished up support for multiple-directories. See commit 6a15c7d 896e507
@gamepoet
Owner

Thanks for the pull request!

I would really like to keep the ability to specify explicit glob patterns but I can't think of a good way to allow that and get the directory prefixing feature you've added. I'll accept your patch for now and think more on it ...

@gamepoet gamepoet merged commit 8d78bbc into gamepoet:master Aug 25, 2012
@gamepoet
Owner

So I after some thinking I came up with an API to allow both the use of explicit glob patterns for files and still keep your relative-path template names. Check out commit 0511167. The updated API is described in the README.

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