Comments (12)
I currently use vash templates to generate static content. It doesn't seem that this is currently a supported scenario, but I was able to make it work by using some undocumented functions.
For example, currently I do this at the global level:
vash.config.settings = vash.config.settings || {};
vash.config.settings.views = path.resolve('./views');
And then when I render the template I do it like this:
var rendered = tpl(model, function sealLayout(err, ctx) {
ctx.finishLayout(); // TODO: undocumented
});
from vash.
Me too! I'm also planning on using it inside a product (Windows desktop application) to generate static HTML files to be later uploaded to a webserver (through a completely other component).
Altough I'm just starting to evaluate your engine, I would love to have everthing that makes generating static files for local disk storing easier 👍
from vash.
@pstephens, that's awesome, and although undocumented, is pretty much how it's supposed to work. One thing I might change in 0.8 is that the layout helpers may become a separate package, but should keep the api the same.
@UweKeim if you do find things working or not, please let me know so I can try to make it easier. Right now static files are pretty easy, although when you start using the layout helpers they get a bit more complex.
You should be able to do something like:
$ vash --json '{ "settings": { "views": "path/to/views/root/" } }' --file main-static-entry.vash --render --out index.html
from vash.
Thanks, @kirbysayshi! Being new to GitHub, I've put a feature request here since I did not find a "real" discussion forum. Is this the correct way of doing it?
from vash.
Yes, vash's GH issues area also functions as a discussion forum. I thought it best to keep things consolidated.
from vash.
Hey @kirbysayshi, any ETA on when 0.8 might be rolling out? I'm starting a new project soon'ish and would love to have 0.8 included from the start. I'm mostly interested in the streaming support because I'd like to build my response pipeline around streams.
from vash.
@dizlexik Contrary to what I said above, the next version will likely not have streaming support, as it's already taken too long to get out and I haven't actually implemented it yet. But in the meantime, you can probably do something like this to "fake" stream, depending on what you actually want streaming to mean:
(warning, untested code)
var vash = require('vash');
var through = require('through2');
somestream.pipe(vashstream()).on('data', function(tpl) {
tpl({ blah: 'ok?' });
});
function vashstream() {
var buf = '';
return through(function(chunk, enc, cb) {
buf += chunk;
cb();
}, function(cb) {
this.push(vash.compile(buf));
cb();
});
}
from vash.
btw @dizlexik, what does streaming support mean to you? The parsing/compilation of the template, or the rendering? I'm guessing only the parsing/compilation is doable as a stream.
from vash.
Thanks for the stopgap code. I'll be using Koa and was hoping for something to the effect of this.body = tpl.stream(mymodel)
. My goal is to start sending my response immediately and not have to buffer the entire thing into memory first. Although the more I think about it the more I'm not even sure that makes sense with vash since there's really no concept of async operations within a template as far as I'm aware.
from vash.
That's where my thinking has been leading as well: I'm not sure streaming has a significant value for a template that is essentially synchronous.
One thing I haven't experimented with at all is generators within a template, which would then blow the entire synchronous model apart. Perhaps a future version of vash...
~ Drew
On Mar 2, 2015, at 2:21 PM, Joe Lutz [email protected] wrote:
Thanks for the stopgap code. I'll be using Koa and was hoping for something to the effect of this.body = tpl.stream(mymodel). My goal is to start sending my response immediately and not have to buffer the entire thing into memory first. Although the more I think about it the more I'm not even sure that makes sense with vash since there's really no concept of async operations within a template as far as I'm aware.
—
Reply to this email directly or view it on GitHub.
from vash.
Going to close, as 0.8.0 has been released with a mostly unchanged api.
from vash.
I've been looking into Koa recently, and came across the Marko template engine that does streamed template rendering and supports async rendering of HTML fragments as it leverages progressive rendering in the browser. Check out this short screencast about it.
This looks interesting and maybe can provide some inspiration for Vash to support similar features :)
from vash.
Related Issues (20)
- Feature Request: Add support for render method HOT 5
- How to make multiple includes for the same component work? HOT 2
- <a> is not considered a void tag, should it?
- ..
- vash block error with koa HOT 6
- Vash HOT 2
- @foreach razor syntax HOT 3
- Conditions inside templates HOT 1
- <a href="@item.html">... HOT 3
- Missing output when using if/else if/else followed by another if HOT 3
- Use syntax highlighting in README.md HOT 1
- Output for blocks with the commandline tool or compile API HOT 2
- [question] How to use vash.helpers.include HOT 1
- Is this library no longer developing? HOT 2
- UnclosedNodeError: Found unclosed VashMarkup HOT 2
- Add Support for Tag Helpers
- Add support for compile file
- Trying to get in touch regarding a security issue HOT 2
- Add TypeScript definitions
- Error running the CodePen playground
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vash.