# helper-ask

> Async helper that prompts the user for a value and uses the answer as context for rendering the template.

Latest version **0.2.1** (published 2016-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install helper-ask
pnpm add helper-ask
yarn add helper-ask
bun add helper-ask
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2016-10-01 |
| First published | 2016-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | answer, ask, cli, context, helper, helpers, interaction, prompt, question, render, template, templates, terminal |

## Links

- npm: https://www.npmjs.com/package/helper-ask
- Repository: https://github.com/helpers/helper-ask
- Issues: https://github.com/helpers/helper-ask/issues
- npm.io page: https://npm.io/package/helper-ask

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [ask-when](https://npm.io/package/ask-when.md) ^0.1.7
- [isobject](https://npm.io/package/isobject.md) ^2.1.0
- [get-value](https://npm.io/package/get-value.md) ^2.0.6
- [has-value](https://npm.io/package/has-value.md) ^0.3.1
- [mixin-deep](https://npm.io/package/mixin-deep.md) ^1.1.3

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2016-10-01
- 0.2.0 — 2016-10-01
- 0.1.4 — 2016-07-14
- 0.1.3 — 2016-07-13
- 0.1.2 — 2016-07-11
- 0.1.1 — 2016-07-01

## README

# helper-ask [![NPM version](https://img.shields.io/npm/v/helper-ask.svg?style=flat)](https://www.npmjs.com/package/helper-ask) [![NPM downloads](https://img.shields.io/npm/dm/helper-ask.svg?style=flat)](https://npmjs.org/package/helper-ask) [![Build Status](https://img.shields.io/travis/helpers/helper-ask.svg?style=flat)](https://travis-ci.org/helpers/helper-ask)

> Async helper that prompts the user for a value and uses the answer as context for rendering the template.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save helper-ask
```

## Compatibility

This helper can be used with the following applications:

* [assemble](https://github.com/assemble/assemble)
* [verb](https://github.com/verbose/verb)
* [update](https://github.com/update/update)
* [generate](https://github.com/generate/generate)
* [templates](https://github.com/jonschlinkert/templates)

## Usage

This helper requires the [base-questions](https://github.com/node-base/base-questions) plugin to be registered first. Uses the [ask-when](https://github.com/jonschlinkert/ask-when) library to conditionally prompt the user. See that project for available options and additional API documentation.

```js
var ask = require('helper-ask');
var questions = require('base-questions');
var templates = require('templates');
var app = templates();

app.use(questions());

// register the helper, make sure to pass `app` to the function
app.asyncHelper('ask', ask(app));
```

**Example**

If you're using [templates](https://github.com/jonschlinkert/templates) directly, you'll need to create a collection and add a template engine.

```js
app.create('pages');
app.engine('*', require('engine-base'));
app.option('engine', '*');
```

With the other apps you should be able to do the following:

```js
var page = app.page('foo', {content: '<%= ask("name") %>'});
app.option('askWhen', 'not-answered');
app.data('name', 'Brian');

app.render(page, function(err, view) {
  if (err) return cb(err);
  console.log(view.contents.toString());
  //=> 'Brian'
  cb();
});
```

## API

**Params**

* `app` **{Object}**
* `returns` **{Function}**: Returns the helper function

**Example**

```html
<%= ask('author.name') %>
```

## About

### Related projects

* [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers): More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… [more](https://github.com/assemble/handlebars-helpers) | [homepage](https://github.com/assemble/handlebars-helpers "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.")
* [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://github.com/jonschlinkert/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers "Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Building docs

_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_

To generate the readme and API documentation with [verb](https://github.com/verbose/verb):

```sh
$ npm install -g verb verb-generate-readme && verb
```

### Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

### License

Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/helpers/helper-ask/blob/master/LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 01, 2016._

---
_Source: https://npm.io/package/helper-ask · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
