This is a fairly complete assemblefile
Shows how to:
- load templates
- use tasks with plugins
- use middleware
- register helpers
/** | |
* @owner Ralf Becher, irregular.bi | |
*/ | |
define( ["jquery", "qlik"], | |
function ($, qlik) { | |
return { | |
//property panel | |
definition: { | |
type: "items", | |
component: "accordion", |
var qsocks = require('qsocks'); | |
var fs = require('fs'); | |
var request = require('request'); | |
//Set our request defaults, ignore unauthorized cert warnings as default QS certs are self-signed. | |
var r = request.defaults({ | |
rejectUnauthorized: false, | |
host: 'usrad-akl.qliktech.com', | |
pfx: fs.readFileSync("C:\\QlikTech\\Demo Team\\Node\\qsocks\\client.pfx") | |
}) |
import * as winston from 'winston'; | |
import * as path from 'path'; | |
let logger = new winston.Logger(); | |
export default { | |
middleware(req, res, next){ | |
console.log('verbose', req.method, req.url, res.statusCode); | |
next(); | |
} |
These rules are adopted from the AngularJS commit conventions.
export class EnumSymbol { | |
sym = Symbol.for(name); | |
value: number; | |
description: string; | |
constructor(name: string, {value, description}) { | |
if(!Object.is(value, undefined)) this.value = value; | |
if(description) this.description = description; |
module.exports = function (assemble) { | |
var middleware = function(params, next) { | |
// do stuff | |
next(); | |
}; | |
// When do you want the plugin to run? | |
middleware.event = 'page:after:render'; | |
return { | |
'assemble-middleware-foo': middleware |
Built-in tags provided by Verb
Verb "tags" are just Lo-Dash templates, which means you have the power of straight JavaScript in your templates.
Verb offers a number of specialized tags that were created to address common needs, but it's easy to add your own custom tags too.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381 | |
/* a helper to execute an IF statement with any expression | |
USAGE: | |
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes | |
-- to access any global function or property you should use window.functionName() instead of just functionName() | |
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later | |
<p> | |
{{#xif " name == 'Sam' && age === '12' " }} | |
BOOM |