Name: helper-ask
Owner: Helpers
Description: Async helper that prompts the user for a value and uses the answer as context for rendering the template.
Created: 2016-07-01 15:31:06.0
Updated: 2016-07-01 15:31:40.0
Pushed: 2016-10-01 09:57:12.0
Homepage: null
Size: 11
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Async helper that prompts the user for a value and uses the answer as context for rendering the template.
Install with npm:
m install --save helper-ask
This helper can be used with the following applications:
This helper requires the base-questions plugin to be registered first. Uses the ask-when library to conditionally prompt the user. See that project for available options and additional API documentation.
ask = require('helper-ask');
questions = require('base-questions');
templates = require('templates');
app = templates();
use(questions());
egister the helper, make sure to pass `app` to the function
asyncHelper('ask', ask(app));
Example
If you're using templates directly, you'll need to create a collection and add a template engine.
create('pages');
engine('*', require('engine-base'));
option('engine', '*');
With the other apps you should be able to do the following:
page = app.page('foo', {content: '<%= ask("name") %>'});
option('askWhen', 'not-answered');
data('name', 'Brian');
render(page, function(err, view) {
(err) return cb(err);
nsole.log(view.contents.toString());
=> 'Brian'
();
Params
app
{Object}returns
{Function}: Returns the helper functionExample
ask('author.name') %>
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
m install -g verb verb-generate-readme && verb
Install dev dependencies:
m install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.31, on October 01, 2016.