Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

br processor

Use for browserify transform and translate code of template engine or pre-proccessor to javascript string.

Build Status Dependencies

Support most pre-precessor which has sync api;

Options

  • processorList
    • matchTest to test file's ext and return boolean to tell browserfiy transform;
    • process a process translate input string to browserify js code;

Demo

Then use for b.transform(transformOpts,brProcessor)

var jade = require('jade');

var transformOpts = {
  processorList: [{
    matchTest: function(file) {
      return /\.jade$/.exec(file);
    },
    process: function(inputString) {
      return html2jsWraper(jade.render(inputString, jadeOpts));
    }
  }]
}

function html2jsWraper(string) {
  return [
    'module.exports=',
    escapeContent(string),
    ';'
  ].join('\'')
}

function escapeContent(content) {
  return content.replace(/\\/g, '\\\\').replace(/'/g, '\\\'').replace(/\r?\n/g,
    '\\n\' +\n    \'');
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages