I am building a Yeoman generator and dependencies needed for this come from https://github.com/sboudrias/mem-fs-editor#copytplfrom-to-context-settings and https://github.com/SBoudrias/Inquirer.js/
The idea is to be able to ask the user a question and repeat the same question i.e. would you like to add another... if the user adds another then it will bind and record that answer and if the user says 'no' or hits return the prompt will stop.
I would like to then have all of the answers binded to an arrary that can be passed to another object function so that it can list out the responses as an array.
Here is the code so far... First is the prompt:
askForTest1: function () {
if (this.type == 'foundation5') {
var cb = this.async();
var prompts = {
type: 'input',
name: 'test1',
message: chalk.yellow(' What is your favorite movie'),
default: 'Star Wars!'
};
this.prompt(prompts, function (props) {
this.templatedata.test1 = props.test1;
cb();
}.bind(this));
}
},
Then is the copyTpl object that will bind options for template builds: This is the desired output I would like to occur... and keep in mind this copy tpl lives in the same index.js file as the prompts. i.e. this template...
this.fs.copyTpl(
this.templatePath('/index2.html'),
this.destinationPath('app/index2.html'),
{ title: [this.templatedata.test1-a, this.templatedata.test1-b, this.templatedata.test1-c, ...], h1: this.applicationName }
);
as a result... a template with this code...
usingwill produce this...
using foo1
using foo2
is this possible and how would I go about doing this.
array.push(value)
to add a value to an array. – Flabbergastvar foo = []; foo.push(3);
will push3
onto the array in thefoo
variable. I don't know of any way that this would modify the DOM. – Flabbergast