Skip to content

Commit

Permalink
added plop.load example code
Browse files Browse the repository at this point in the history
  • Loading branch information
amwmedia committed Nov 18, 2016
1 parent 587060a commit 750e22c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions example/plopfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const path = require('path');

module.exports = function (plop) {
// helpers are passed through to handlebars and made
Expand All @@ -13,9 +14,20 @@ module.exports = function (plop) {
return words.join(', ').replace(/(:?.*),/, '$1, and');
});

plop.addHelper('absPath', function (p) {
return path.resolve(plop.getPlopfilePath(), p);
});

// greet the user using a partial
plop.addPartial('salutation', '{{ greeting }}, my name is {{ properCase name }} and I am {{ age }}.');

// load some additional helpers from a module I "npm install"ed
plop.load('plop-pack-fancy-comments', {
prefix: '',
upperCaseHeaders: true,
commentStart: '',
commentEnd: ''
});

// setGenerator creates a generator that can be run with "plop generatorName"
plop.setGenerator('test', {
Expand Down Expand Up @@ -125,10 +137,13 @@ module.exports = function (plop) {
}
],
actions: [
{
function(data) {
console.log(data);
return 'yay';
}, {
type: 'add',
path: '{{path}}/{{fileName}}.txt',
template: '{{path}}/{{fileName}} plopped!'
path: '{{absPath path}}/{{fileName}}.txt',
template: '{{absPath path}}/{{fileName}} plopped!'
}
]
});
Expand Down
2 changes: 2 additions & 0 deletions example/templates/burger.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{{ header 'Hello Burger Lover!' }}

Here's your burger {{ properCase name }}!

0 comments on commit 750e22c

Please sign in to comment.