
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
gulp-vash-static
Advanced tools
Gulp plugin for converting Vash razor templates to static html
Keep in mind that this is just a thin wrapper around Vash Static and your issue is most likely with that.
$ npm install --save-dev gulp-vash-static
There are a few different functions you can call:
This is my recommended setup, where all you need to call is 'gulp watch' to get started.
var gulp = require('gulp');
var vashStatic = require('gulp-vash-static');
// The default is "pg" anyway, but this is just to show you that you can change it to another directory name if you wish
vashStatic.setPageDirType("pg");
var dirTypes = ["pg", "wg", "glb"]; // vashStatic module types
var APP = "dev/app/";
var PRECOMP_VASH = "precompiled-vash.json" // aka vash cache
gulp.task("precompile-vash", function() {
return gulp.src([
APP + "pg/**/*.vash"
, APP + "wg/**/*.vash"
, APP + "glb/**/*.vash"
, "!" + APP + "glb/vash-helpers/*.vash" // leave out any vash helpers you have
])
.pipe(vashStatic.precompile({
debugMode: true,
dirTypes: dirTypes,
modelsPath: "bld/js/models.js",
cacheFileName: PRECOMP_VASH
}))
.pipe(gulp.dest("bld/"))
})
gulp.task("pg-render-static", function() {
return gulp.src(APP + "pg/**/*.vash")
.pipe(vashStatic.renderPage({
cacheDest: "bld/" + PRECOMP_VASH
, helpers: [ APP "glb/vash-helpers/RenderWidget.vash" ] // optionally, you can add or override (same name) with custom helpers
, omitSubDir: "tmpl" //omit a subdirectory that you might have that you don't want to be part of the template name
}))
.pipe(gulp.dest("bld/"))
})
// Combines models so they can be injected into templates when rendering.
// This is suggested if you need a separate model per page.
// Recommend using TypeScript because of it's similar syntax to C# models, which makes integration of Razor front end and back end easier.
gulp.task("combine-models", function () {
var src = [
APP + "pg/**/mdl/*.ts"
, APP + "wg/**/mdl/*.ts"
];
return gulp.src(src)
.pipe(ts({
noImplicitAny: true,
out: 'models.js'
}))
.pipe(gulp.dest("bld/js/"));
});
/*
Watches for any changes in vash templates or models, updates the precompiled template cache (on the file system), then renders the page marked by a flag (eg --home) by calling the 'pg-render-static' task.
Note that 'vashStatic.watchModelsAndTemplates' is not a gulp plugin, just a convenience function that abstracts away some complex logic.
Returns a stream from gulp plugin 'gulp-watch'.
*/
gulp.task("watch", function() {
var vashSrc = [ // vash templates
APP+"pg/**/*.vash"
, APP+"wg/**/*.vash"
]
, modelSrc = [ // template models
APP + "pg/**/mdl/*.ts"
, APP + "wg/**/mdl/*.ts"
]
return vashStatic.watchModelsAndTemplates({
gulp: gulp // pass in the instance of gulp you are using
, vashSrc: vashSrc
, modelSrc: modelSrc
, modelsDest: "bld/js/models.js" // your combined models to inject when rendering templates
, cacheDest: "bld/" + PRECOMP_VASH // cached templates JSON file, generated by 'precompile-vash' task
, debugMode: true // should be false for production to keep file size down
, dirTypes: dirTypes // module types, eg ['pg', 'wg', 'glb']
, pageTemplatePath: APP + "<%= type %>/<%= moduleName %>/tmpl/<%= fileName %>" // pattern to the vash template, using moduleName from the '--home' flag
// existing gulp tasks to call when files are changed
, combineModelsTask: 'combine-models'
, precompileTask: 'precompile-vash'
, pageRenderTask: 'pg-render-static'
})
})
Vash Static uses modules to organise your templates. By default it assumes you have at least a page module, which is abbreviated to 'pg' and is expected in the directory structure. With 'setPageDirType' you can change this, if you need to.
Gets the argument from the command-line that starts with '--', omitting the '--' and finishing at the next space. The watch on models cannot detect the exact page that needs to be rendered, so assumes 'Index.vash'. You can specify a different page though by adding a '/MyPageName' (omit the file extension).
Allows you to optionally override the functionality of 'getAllArgs', so you can manipulate arguments. First param should be the function and it should return a manipulated string containing the page name.
Restores 'getAllArgs' after using 'overrideGetAllArgs'.
This can be useful if you don't want to output lots of warnings in things like unit tests (which can be annoying).
Precompiles a vash templates and generates a json file with the template's name and contents in it.
Precompiles a vash templates and generates a json file with the template's name and contents in it.
Convenience function for watching models and templates
getFirstArg
was replaced by getAllArgs
overrideGetFirstArg
was replaced by overrideGetAllArgs
restoreGetFirstArg
was replaced by restoreGetAllArgs
MIT © Jim Doyle
FAQs
Gulp plugin for converting Vash razor templates to static html
We found that gulp-vash-static demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.