SlexAxton / require-handlebars-plugin

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

Add helpers from another repo (ie swag) #222

Open kusmierz opened 9 years ago

kusmierz commented 9 years ago

I'm trying to integrate http://www.github.com/elving/swag with http://www.github.com/SlexAxton/require-handlebars-plugin. Swag will register their helpers using Handlebars.registerHelper method. It's all fine, unless you are trying to build it (r.js -o build.js). Builder can\'t see dynamic loaded helpers.

So I had to add to my build.js file:

({
    'name': 'app',
    //...
    'paths': {
        'templates/helpers/lowercase': 'empty:',
        'templates/helpers/uppercase': 'empty:',
        'templates/helpers/capitalizeFirst': 'empty:',
        'templates/helpers/capitalizeEach': 'empty:',
        'templates/helpers/titleize': 'empty:',
        'templates/helpers/sentence': 'empty:',
        'templates/helpers/reverse': 'empty:',
        'templates/helpers/truncate': 'empty:',
        'templates/helpers/center': 'empty:',
        'templates/helpers/newLineToBr': 'empty:',
        'templates/helpers/sanitize': 'empty:',
        'templates/helpers/first': 'empty:',
        'templates/helpers/withFirst': 'empty:',
        'templates/helpers/last': 'empty:',
        'templates/helpers/withLast': 'empty:',
        'templates/helpers/after': 'empty:',
        'templates/helpers/withAfter': 'empty:',
        'templates/helpers/before': 'empty:',
        'templates/helpers/withBefore': 'empty:',
        'templates/helpers/join': 'empty:',
        'templates/helpers/sort': 'empty:',
        'templates/helpers/withSort': 'empty:',
        'templates/helpers/length': 'empty:',
        'templates/helpers/lengthEqual': 'empty:',
        'templates/helpers/empty': 'empty:',
        'templates/helpers/any': 'empty:',
        'templates/helpers/inArray': 'empty:',
        'templates/helpers/eachIndex': 'empty:',
        'templates/helpers/eachProperty': 'empty:',
        'templates/helpers/add': 'empty:',
        'templates/helpers/subtract': 'empty:',
        'templates/helpers/divide': 'empty:',
        'templates/helpers/multiply': 'empty:',
        'templates/helpers/floor': 'empty:',
        'templates/helpers/ceil': 'empty:',
        'templates/helpers/round': 'empty:',
        'templates/helpers/toFixed': 'empty:',
        'templates/helpers/toPrecision': 'empty:',
        'templates/helpers/toExponential': 'empty:',
        'templates/helpers/toInt': 'empty:',
        'templates/helpers/toFloat': 'empty:',
        'templates/helpers/digitGrouping': 'empty:',
        'templates/helpers/is': 'empty:',
        'templates/helpers/isnt': 'empty:',
        'templates/helpers/gt': 'empty:',
        'templates/helpers/gte': 'empty:',
        'templates/helpers/lt': 'empty:',
        'templates/helpers/lte': 'empty:',
        'templates/helpers/or': 'empty:',
        'templates/helpers/and': 'empty:',
        'templates/helpers/formatDate': 'empty:',
        'templates/helpers/now': 'empty:',
        'templates/helpers/timeago': 'empty:',
        'templates/helpers/inflect': 'empty:',
        'templates/helpers/ordinalize': 'empty:',
        'templates/helpers/ul': 'empty:',
        'templates/helpers/ol': 'empty:',
        'templates/helpers/br': 'empty:',
        'templates/helpers/log': 'empty:',
        'templates/helpers/debug': 'empty:',
        'templates/helpers/default': 'empty:',
    }
})

Now it works fine, but I don't know it it's the best idea to do like this...