{%= description %}
Inspired by conversations with Jon Schlinkert
{%= include("install-npm", {save: true}) %}
var question = require('{%= name %}');
var context = {questions: {name: "What's your name?"}};
// Prompt a user for a question and get an answer back.
question.call({ctx: context}, "name", function (err, answer) {
if (err) return console.log('error', err);
console.log('Answer', answer);
});
Params
key
{String}: Either a key on aquestions
object on the context or a question to ask.options
{String}: Additional options to pass.next
{Function}: Callback function that will be passed an error and/or the results of asking the question.
To use with template:
npm i template --save
Then add to your project.
var template = require('template');
handebars
Register handlebars as an engine:
template.engine('hbs', require('engine-handlebars'));
var question = require('question-helper');
var context = {questions: {name: "What's your name?"}};
template.page('author.hbs', "Author: {{question 'name'}}");
template.render('author.hbs', context, function (err, content) {
if (err) return console.log('error', err);
console.log(content);
});
Lo-Dash
Register Lo-Dash as an engine:
template.engine('html', require('engine-lodash'));
var context = {questions: {name: "What's your name?"}};
template.page('author.html', "Author: <%= question('name') %>");
template.render('author.html', context, function (err, content) {
if (err) return console.log('error', err);
console.log(content);
});
{%= include("tests") %}
{%= include("contributing") %}
{%= related(['template-helpers', 'handlebars-helpers', 'template', 'engine-handlebars', 'engine-lodash']) %}
{%= include("author") %}
{%= copyright() %} {%= license() %}
{%= include("footer") %}