0.9.0: Adding helpers from `verbfile.js`?
See original GitHub issueThat’s strange. I tried in a couple of ways that i know that it should work. Also checked how it’s done on other libs and generators.
The #91 “problem” push me to try some things and start playing with toc
options and verb in general. In a result I realize couple of things:
- there’s no
toc
template helper - e.g. using{%= toc() %}
- you can’t pass options for
toc
through<!-- toc -->
- i seen somewhere thing like
<!-- toc('*.md', opts) -->
- so i tried
toc('README.md', {filter: fn})
, but not works - the html comment is the same
- i seen somewhere thing like
- can’t overwrite toc options? - the easiest way to try that was to add
toc: {footer: 'foo'}
to pkg - then i tried to add to verbfile (exposing function) some sync helper manually
- tried using it in verbfile
{%= foo('bar') %}
and failed withfoo is not defined
- tried
verb.helper('foo', require('helper-date'))
- again fails withfoo is not defined
- tried to create task, add above to it and execute it - not works.
- tried using
verb.extendWith
and put some tasks/helpers in it - not works.
- tried using it in verbfile
So, couple of problems
- there’s a need to expose
helper-toc
to template, b/c currently it only can be from<!-- -->
- there’s no way to add filter (in general any) options to toc, neither through config and template
- there’s some problem adding helpers
edit: Tried everything that I can think for. edit2: One of the tried ways:
'use strict'
module.exports = function generator(verb) {
verb.extendWith(function (app) {
// console.log('app', app)
app.task('foobar', function (cb) {
console.log('actual')
app.helper('foo', function () {
console.log('helper')
return 123
})
cb()
})
app.build('foobar', function (err, res) {
console.log('build', err, res)
})
})
}
Fails with foo is not defined
[charlike@voltaire async-simple-iterator]$ verb
[20:00:54] using verbfile ~/dev/__play/async-simple-iterator/verbfile.js
[20:00:54] starting default generator
[20:00:54] starting default:foobar task
actual
[20:00:54] finished default:foobar task 2ms
[20:00:54] finished default generator 14ms
build undefined undefined
[20:00:54] starting readme generator
[20:00:54] starting readme:readme task
[20:00:54] starting readme generator
[20:00:55] finished readme generator 50ms
ReferenceError: foo is not defined
at eval (engine.templateSources[1]:16:11)
at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/engine-cache/index.js:201:17
at Object.wrappedRender [as render] (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/engine-cache/index.js:256:7)
at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/templates/lib/plugins/render.js:291:16
at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/templates/lib/plugins/routes.js:133:7
at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:576:15
at next (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:161:14)
at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:183:18
at Function.matchLayer (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:264:3)
at next (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:164:10)
ENV: <Generator default [string] /home/charlike/dev/__play/async-simple-iterator/verbfile.js>
The another again fails with above output. It was simply:
'use strict'
module.exports = function generator(verb) {
verb.helper('foo', require('helper-date'))
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:38 (23 by maintainers)
Top Results From Across the Web
verbose/verb-generate-readme - GitHub
This generator requires verb 0.9.0 and up, which is currently on the dev branch ... Each time the verb command is run, verb's...
Read more >verb-readme-generator - npm Package Health Analysis - Snyk
This generator requires verb 0.9.0 and up, which is currently on the dev ... If you need more granularity just add a verbfile.js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
lol thanks!
@jonschlinkert I’m damn awesome 😄 The comment was collapsed. https://github.com/node-base/base-debug/pull/3#discussion_r54457216