Skip to content

Commit

Permalink
move html_to_text from thunder to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-lin committed Jul 6, 2013
1 parent 3c27a25 commit 55b7884
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
4 changes: 0 additions & 4 deletions Readme.md
Expand Up @@ -171,10 +171,6 @@ For advance usages please checkout the API block.


## API ## API


### thunder.html_to_text( input );

Compile the HTML templates to JavaScript strings. It is only used for client-side templates.

#### Arguments #### Arguments


> input > input
Expand Down
7 changes: 0 additions & 7 deletions lib/thunder.js
Expand Up @@ -32,13 +32,6 @@


version : '0.1.6', version : '0.1.6',


// for client-side
html_to_text : function ( input ){
return input.
replace( /\"/g, '\\\"' ).
replace( /\n/g, '\\n\\\n' );
},

compiled_text : function ( input, options ){ compiled_text : function ( input, options ){
var arr = ( options && options.compress === true ? var arr = ( options && options.compress === true ?
// compress // compress
Expand Down
18 changes: 12 additions & 6 deletions lib/utils.js
Expand Up @@ -7,11 +7,10 @@
* Utility functions for builing ommand line tools. * Utility functions for builing ommand line tools.
*/ */


var fs = require( 'fs' ); var fs = require( 'fs' );
var mkdirp = require( 'mkdirp' ); var mkdirp = require( 'mkdirp' );
var rmdir = require( 'rmdir' ); var rmdir = require( 'rmdir' );
var color = require( 'cli-color' ); var color = require( 'cli-color' );
var thunder = require( 'thunder' );


module.exports = { module.exports = {


Expand Down Expand Up @@ -45,6 +44,13 @@ module.exports = {
return str; return str;
}, },


// for client-side
html_to_text : function ( input ){
return input.
replace( /\"/g, '\\\"' ).
replace( /\n/g, '\\n\\\n' );
},

write : function ( layout, input_path, output_path, use_requirejs ){ write : function ( layout, input_path, output_path, use_requirejs ){
var output_dir = output_path.replace( this.regex.file_name, '$1' ); var output_dir = output_path.replace( this.regex.file_name, '$1' );
var is_dir = output_dir === output_path; var is_dir = output_dir === output_path;
Expand All @@ -62,7 +68,7 @@ module.exports = {
} }


var src = fs.readFileSync( input_path, 'utf8' ); var src = fs.readFileSync( input_path, 'utf8' );
var tmp = thunder.html_to_text( src ); var tmp = this.html_to_text( src );
var tpl = layout.replace( '__content__', tmp ); var tpl = layout.replace( '__content__', tmp );


if( use_requirejs == 'false' ){ if( use_requirejs == 'false' ){
Expand Down

0 comments on commit 55b7884

Please sign in to comment.