Code Monkey home page Code Monkey logo

node-underscorify's People

Contributors

alexstrat avatar chrisjhoughton avatar maxparm avatar ryanmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-underscorify's Issues

Not compatible with Watchify

After a change, the following output is produced

module.exports=function(obj){{var __t,__p="";Array.prototype.join}with(obj||{})__p+=module.exports=function(obj){{var __t,__p="";Array.prototype.join}with(obj||{})__p+=

It gets duplicated every time the watch fires

htmlparser error

Hi,
I followed the instructions and ran browserify -t node-underscorify content.js > content-bundle.js but I get this error:

Error: module "./htmlparser" not found from "/Users/macuser/prj/static/node_modules/node-underscorify/node_modules/html-minifier/dist/htmlminifier.js"
    at notFound (/usr/local/lib/node_modules/browserify/index.js:812:15)
    at /usr/local/lib/node_modules/browserify/index.js:762:23
    at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/index.js:185:24
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:35:22
    at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:53:43)
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:59:22
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:16:47
    at Object.oncomplete (fs.js:107:15)

Allow setting config through package.json

I'm able to add node-underscorify to browserify's transform array via package.json, but it'd be great to also be able to specify the node-underscorify options here as well.

Doesn't Appear to Observe Options Passed via grunt-browserify

I'm attempting to pass templateSettings via grunt-browserify. My Gruntfile looks like:

var template_opts = {
    interpolate:    /\{\{(.+?)\}\}/g,
    escape:         /\{-(.+?)\}/g,
    evaluate:       /<%(.+?)%>/g
};

module.exports = function( grunt ) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        browserify: {
            spec: {
                options: {
                    transform: [['node-underscorify', { templateSettings: template_opts }]],
                    browserifyOptions: {
                        debug: true
                    }
                },
                src:    ['app/config.js','spec/**/*-spec.js'],
                dest:   'spec/bundle.js'
            }
        }
    });

    grunt.loadNpmTasks( 'grunt-browserify' );
};

The compiled code doesn't use the specified delimiters.

Templates with node_modules in Path Ignored

And file (template) with node_modules in its path is ignored by this transform. This may be an expected behavior in Browserify, but if that's the case I'd recommend documenting how to override it. Happy to help track this down later, but wanted to capture the information while I was thinking about it.

Underscore not global

Hi,
node-underscorify works like charm if underscore is set as global, but I need to use it locally for my modules, how can I setup underscore with shim when I require my templates ?

I tried something like that in my grunt file but unfortunately it doesn't work :

Grunt file

shim: {
underscore:  {
  path: 'vendor/underscore/underscore.js',
  exports: '_'
},
templates: {
  path: 'templates/**/*.html',
  exports: null,
  depends: {
       underscore: 'underscore'
 }
}

Module file

var _ = require('underscore');
var MyTemplates = require('templates/my-template.html');

Thanks.

How can this be used in node? (for tests)

I'm writing tests to run in node.js with mocha via jsdom (following this example) and I notice node-underscorify does not have an effect when the require() is done outside of browserify (makes sense). Is there any way to run my require() through node-underscorify outside of browserify? Or am I going about testing all wrong?

Update html-minifier dependency version

The html-minifier dependency is currently configured at 0.5.6.

New versions offer the ignoreCustomFragments option which allows minification to occur correctly in some underscore template use-cases.

For example:

<select>  <option value="1" <%= selected ? "selected" : "" %> ></option>  </select>

Does not parse properly with html-minifier 0.5.6. Newer versions have added the ignoreCustomFragments option which allows the minifier to ignore underscore template blocks. This can be used like so for the default underscore template syntax:

ignoreCustomFragments: [/<%[^%]*%>/]

Ease contribution

To ease contribution:

  • add a ~npm build command
  • not version generated JS files but rather use prepublish scripts
  • add your version of coffee in devDependencies
  • add npm test script
  • (opt.) add CONTRIBUTING.md

Thx!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.