-
Notifications
You must be signed in to change notification settings - Fork 60
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
Adding Express rendering methods #6
Comments
Vash used to be compatible with express out of the box, but apparently I've fallen behind with those updates. Especially with express 3, which puts I'm thinking two things:
When using Vash client-side, none of this is an issue. It's easy to just reference the "template store" from within a template, So, having said that... if you're up to trying to implement this (it's really not that hard, honest!), definitely let me know and give it a shot. Otherwise, I'll add it to my list. |
I was looking into consolidate as well... perhaps that's the easiest, but I was thinking adding renderFile to Vash would be cleanest. |
Well, renderFile is just something that jshtml cooked up, it's not part of any particular spec. I would recommend consolidate, or even just express support straight up:
Consolidate is basically the same thing. The difficult part is not getting express to use Vash, it's adding in things like partials, layouts and/or blocks. For that, I'm actually thinking I might need a second project/package called vash-ve, for view engine. |
Yes, I understand now that Vash was in the first place meant to be a lexer more than a view engine. Vash-ve might be more appropriate indeed, sorry. |
Ha, yeah no. :) I just pushed basic express support: https://github.com/kirbysayshi/Vash/blob/2317997e8eb1b577daf2dcbe00926ab60f47cec6/src/vexpress.js. You should be able to just do |
Thanks! Much appreciated. Out of the country for 10 days, so sublimetext will be waiting for me when I get back to continue! |
As of right now, the code in master has a much of view engine support: d5c8ef3. It also supports express a little better. The next stab at this will have to be a big rewrite, because a lot of this stuff should be handled at compile time, and not at runtime (like it is now). |
Hello, Nice work. Just poked around a bit with vash, but got the following error when trying to hook vash into express:
I think the following code in the vash lib might cause this: filepath = filepath.indexOf(options.settings.views) > -1
? filepath
: options.settings.views
+ '/' + filepath
+ '.' + options.settings['view engine']; Which renders to this path: |
Yep, that makes perfect sense. I assume in your call to Don't get me wrong, this is definitely a bug, but this is the simple fix you can do while I patch things up. |
Could you post your I thought I had this fixed, but I had misread your report. I missed that in addition to the double extension, you are also getting weird double paths. If you post the above things, it will help me narrow things down. |
I'm using the LocomotiveJS framework, which does the res.render call I think. this.set('views', __dirname + '/../../app/views');
this.set('view engine', 'vash');
this.engine('vash', vash.__express); |
Grab the newest version from NPM, and add this line, if your views end with
And then please post the error if any. |
Yeah it tries to load pages\main.html.vash now :) (which is correct) this.set('view engine', 'vash');
this.engine('vash', vash.__express); EDIT: and for a different extension:
|
I've never seen locomotive before. I think part of the problem is the way you're specifying your views folder. I don't think it's necessary, since the locomotive guide for views doesn't have it. You should only need:
And if you're using templates that have
|
So it's working now? My last comment posted at the same time as yours... I'm on bad hotel internet so it took forever. |
It's too soon to tell if everything is working, but this part definitely does work. The razor templating can begin! :D |
Ok, good to hear. If you encounter any more bugs, open a new ticket! |
First of all, kudos on this project!
Vash is only a "template-maker" at the moment, and can't be used with Express out of the box (that I know of? :P)
https://github.com/elmerbulthuis/jshtml/blob/master/index.js
That file (and in particular, the .render method) makes the lexer of that Razor renderer an actual template engine that is compatible with Express.
I would greatly appreciate the option of being able to integrate Vash with Express :)
The text was updated successfully, but these errors were encountered: