jonschlinkert / templates

System for creating and managing view collections, rendering, engines, routes and more. See the "dev" branch for most recent updates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: this.debug.helpers is not a function

tunnckoCore opened this issue · comments

Using latest dev branch of verb, so templates is latest v0.14.5 (i checked it).

[charlike@voltaire bind-context]$ verb
/usr/local/lib/node_modules/verb/node_modules/templates/lib/plugins/helpers.js:79
    this.debug.helpers('getting async helper "%s"', name);
               ^

TypeError: this.debug.helpers is not a function
    at Verb.<anonymous> (/usr/local/lib/node_modules/verb/node_modules/templates/lib/plugins/helpers.js:79:16)
    at Verb.<anonymous> (/usr/local/lib/node_modules/verb/node_modules/templates/lib/plugins/helpers.js:116:24)
    at Object.module.exports (/usr/local/lib/node_modules/verb/node_modules/templates/lib/helpers/singular.js:7:11)
    at Verb.Templates.create (/usr/local/lib/node_modules/verb/node_modules/templates/index.js:316:11)
    at Verb.initVerb (/usr/local/lib/node_modules/verb/index.js:61:10)
    at new Verb (/usr/local/lib/node_modules/verb/index.js:32:8)
    at Verb (/usr/local/lib/node_modules/verb/index.js:28:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/verb/bin/verb.js:12:11)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

And actually I can't realize how debug comes into utils, it's unreal hahaha, absolute absurd.

edit: Let's start. ./lib/debug.js is called on the constructor on line 56. In this file lazy-loaded modules and all files from lib/utils/* are merged, okey.

Adding console.log(this.debug) before line 79 in lib/plugins/helpers.js mostly output correct and expected object, but the last is

{ [Function: disabled]
  enabled: false,
  namespace: 'base:templates:assemble:generate:verb',
  append: [Function] }

If I comment the whole debug things in this file, same error comes from lib/plugins/engine.js:58 which again is debug, sooo.. it seems that lib/utils.js (actually debug function from lib/utils/common.js) is not called (because it adds these methods) some times, strange.

does sound strange. I'll look into, it's probably an oversight somewhere

the output is great though, it's already coming in useful (even more once we get the kinks out!).

like how we did the namespace thing? :)

like how we did the namespace thing?

Yea, looks good.

Is there any quick fix? Or any ideas? From where to start? I tried to manually install previous versions of base and templates, generate and assemble-core, but not success.
This bug blocked my using of verb ;/

Okey, i have idea. We should drop the debug thing from base/index.js#L107-111 and replace it with this.use(baseDebug()) (the base-debug plugin). I'm trying it locally with latest verb installed.

yeah, agreed that's already the plan. the plugin isn't done correctly - or at least how I want it to work, and I just wanted to get debug working because it's helping us get everything prepared for release

Damn, I just realize it 😆

Problem is that verb not follow the new "debug" style, yet. Meaning, in templates, assemble-core and generate, there is var debug = Assemble.debug; then that debug should be called with this in every app constructor. That is lil' bit shitty need. :D

I think we should remove all this static .debug method, that lib/debug.js thing, and all namespacing from base.is. I think all namespacing and debug is job of base-debug plugin.

Also, this utils.namespace function in base/utils.js is incorrect, it tries to split this._name by :, but really (don't need to split) it can't contain it, or if it can then is* would be shit. For example

function MyApp () {
  Base.call(this)
  this.is('app:bar:baz')
  console.log(this._namespace) // => base:app:baz:bar
  console.log(this['isApp:bar:baz']), // => true
}

You may say that .is is intended to be used with single word and/or without colons and shit characters - yes, but then why you split it by colons (in base/utils.js the utils.namespace function)? Good idea can be to namify over coming name (which is set to this._name).

edit: actually, yea, both namespace and debug plugin not works correctly, as you said. :)

Problem is that verb not follow the new "debug" style, yet.

oh, yeah you're one step ahead of me. I already implemented this in verb locally but didn't realize it wasn't pushed up. I'll do that in a moment.

Also, this utils.namespace function in base/utils.js is incorrect, it tries to split this._name by :, but really (don't need to split) it can't contain it, or if it can then is* would be shit

If you want to add : to the isFoo:bar:baz then why shouldn't you be able to do that? what am I missing?

If you want to add : to the isFoo:bar:baz then why shouldn't you be able to do tha

hmm, when i rethink it.. okey 👍

fixed

Great, i'll try.