SlexAxton / require-handlebars-plugin

A plugin for handlebars in require.js (both in dev and build)
804 stars 202 forks source link

Error: Missing helper: 'yeller' #226

Closed dreamdeveloper closed 9 years ago

dreamdeveloper commented 9 years ago

Hi, for two days, I try to eliminate the error "Error: Missing helper: 'yeller' ". I'm think that's pieces of code help you to understand my problem, Thanks and please help.

:dash: templates/helpers/yeller.js

define(['handlebars'], function ( Handlebars ){
  var yeller = function( context ) {
    // Assume it's a string for simplicity.
    return context + "!!!!!!!!";
  }

  Handlebars.registerHelper("yeller", yeller);
  return yeller;
});

:droplet:views/WelcomeView.js

define( ['App', 'backbone', 'marionette', 'jquery', 'models/Model', 'hbs!templates/welcome'],
    function(App, Backbone, Marionette, $, Model, template) {
        //ItemView provides some default rendering logic

        return Backbone.Marionette.ItemView.extend( {
            template: template,
            model: new Model({
                mobile: App.mobile
            }),

            // View Event Handlers
            events: {

            }
        });
    });

:pray: config.js

require.config({
    baseUrl:"./javascript/app",
    // 3rd party script alias names (Easier to type "jquery" than "libs/jquery, etc")
    // probably a good idea to keep version numbers in the file names for updates checking
    paths:{
        // Core Libraries
        "jquery":"../libs/jquery",
        "jqueryui":"../libs/jqueryui",
        "jquerymobile":"../libs/jquery.mobile",
        "underscore":"../libs/lodash",
        "backbone":"../libs/backbone",
        "marionette":"../libs/backbone.marionette",
        "handlebars":"../libs/handlebars",
        "hbs":"../libs/hbs",
        "i18nprecompile":"../libs/i18nprecompile",
        "json2":"../libs/json2",
        "jasmine": "../libs/jasmine",
        "jasmine-html": "../libs/jasmine-html",

        // Plugins
        "backbone.validateAll":"../libs/plugins/Backbone.validateAll",
        "bootstrap":"../libs/plugins/bootstrap",
        "text":"../libs/plugins/text",
        "jasminejquery": "../libs/plugins/jasmine-jquery"
    },
    // Sets the configuration for your third party scripts that are not AMD compatible
    shim:{
        // Twitter Bootstrap jQuery plugins
        "bootstrap":["jquery"],
        // jQueryUI
        "jqueryui":["jquery"],
        // jQuery mobile
        "jquerymobile":["jqueryui"],

        // Backbone
        "backbone":{
            // Depends on underscore/lodash and jQuery
            "deps":["underscore", "jquery"],
            // Exports the global window.Backbone object
            "exports":"Backbone"
        },
        //Marionette
        "marionette":{
            "deps":["underscore", "backbone", "jquery"],
            "exports":"Marionette"
        },
        //Handlebars
        "handlebars":{
            "exports":"Handlebars"
        },
        // Backbone.validateAll plugin that depends on Backbone
        "backbone.validateAll":["backbone"],

        "jasmine": {
            // Exports the global 'window.jasmine' object
            "exports": "jasmine"
        },

        "jasmine-html": {
            "deps": ["jasmine"],
            "exports": "jasmine"
        }
    },
    // hbs config - must duplicate in Gruntfile.js Require build
    hbs: {
        helpers: true,
         disableI18n : false,

        templateExtension: "html",
        helperDirectory: "templates/helpers/",
        i18nDirectory: "templates/i18n/",
        compileOptions: {}        // options object which is passed to Handlebars compiler
    }
});

:droplet:templates/welcome.html

<div class="hero-unit">
    <h1>Marionette-Require-Boilerplate</h1>
    <p>Boilerplate Marionette application to help you get started with the best tools and best practices</p>

    <p class="muted">
        You are viewing this application on
        {{#if mobile}}
        {{!"mobile" key in i18n file}}
        <strong>{{$ mobile}}</strong>
        {{else}}
        {{!"desktop" key in i18n file}}
        <strong>{{$ desktop}}</strong>
        {{/if}}.
        {{yeller "This helper don't work"}}
    </p>
    <p>Part of the <a href="https:github.com/BoilerplateMVC/">BoilerplateMVC suite</a>.</p>
</div>
dreamdeveloper commented 9 years ago

Fucking shit, I'm downloaded "Underscore.min.js" instead of "Lodash.js", and this work for me.