nesta icon indicating copy to clipboard operation
nesta copied to clipboard

Nesta ignores theme’s .slim templates

Open agarzola opened this issue 11 years ago • 4 comments

After following these instructions to switch the templating engine to Slim, Nesta is throwing this error:

No such file or directory - /Users/agarzola/.rvm/gems/ruby-1.9.2-p290/gems/nesta-0.9.13/views/page.slim

However, my theme does contains a page.slim template (I’ve renamed all of my theme’s templates to .slim), so it would seem that Nesta is ignoring my theme’s templates. I tried switching to Erb and did not get this error, so it seems to have something to do with Slim specifically.

Here’s the app.rb in my theme’s directory (/themes/v2/app.rb), in case it helps you spot any mistakes I may have made.

Thanks!

agarzola avatar Jan 06 '14 22:01 agarzola

Sorry about this. You've discovered a weakness in the way Nesta looks for templates in themes.

Sinatra only looks in one folder for templates, so to support reading templates from different locations (either the theme, or the site's local ./views folder) Nesta redefines the Sinatra methods that render each template (e.g. haml, erb, etc), teaching it how to look in multiple locations.

The code that does it is here (in the Renderers module): https://github.com/gma/nesta/blob/master/lib/nesta/overrides.rb

If you definitely need a theme, the easiest solution would be to define Nesta::Overrides::Renderers#slim (to do the same thing as the existing methods, only for slim) in your app.rb file. If you don't really need a theme (and are just styling one site) you'll probably find that slim will just work if you make a ./views folder and move your templates into that instead.

Thanks for reporting it.

gma avatar Jan 07 '14 10:01 gma

Thanks for providing options, Graham! I'll follow your suggestion of moving my views directory to the root of the project. I don't really need themes. Not yet, anyway.

Thanks again!

agarzola avatar Jan 07 '14 11:01 agarzola

Actually, I decided to try out defining a slim method to my app.rb. However, is this something you would consider adding to the gem? It would be a more permanent solution, methinks. I’d happily add it and send a pull request if you’d prefer.

agarzola avatar Jan 07 '14 15:01 agarzola

On 7 Jan 2014, at 15:46, Alfonso [email protected] wrote:

Actually, I decided to try out defining a slim method to my app.rb. However, is this something you would consider adding to the gem? It would be a more permanent solution, methinks. I’d happily add it and send a pull request if you’d prefer.

Definitely. There’ll be a nicer solution in the long term, where it just infers what it needs to support (there’s a big discussion on it in one of the other bug reports), but in the meantime I’ll happily accept a pull request.

You’d need to install the gem from gma/master for a while though to get the fix (until I release 0.10.0).

gma avatar Jan 07 '14 16:01 gma

This will have been fixed by 19ec573c06a9443091919e9142ded96e92fbf76c, which will be included in the next release (0.14.0).

gma avatar Mar 12 '23 10:03 gma