Skip to content

Latest commit

 

History

History
98 lines (66 loc) · 2.25 KB

.verb.md

File metadata and controls

98 lines (66 loc) · 2.25 KB

{%= name %} {%= badge("fury") %} {%= badge("travis") %}

{%= description %}

Inspired by conversations with Jon Schlinkert

{%= include("install-npm", {save: true}) %}

Usage

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 a questions 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.

Template

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);
});

Running tests

{%= include("tests") %}

Contributing

{%= include("contributing") %}

Related

{%= related(['template-helpers', 'handlebars-helpers', 'template', 'engine-handlebars', 'engine-lodash']) %}

Author

{%= include("author") %}

License

{%= copyright() %} {%= license() %}


{%= include("footer") %}