Skip to content

Commit

Permalink
Merge pull request #118 from bitovi/nameclash-118
Browse files Browse the repository at this point in the history
can.EJS template rendering issue #118
  • Loading branch information
daffl committed Jan 11, 2013
2 parents 4616fb3 + 1fc1cd4 commit 652043b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions util/string/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ steal('can/util',function(can) {
// Several of the methods in this plugin use code adapated from Prototype
// Prototype JavaScript framework, version 1.6.0.1.
// © 2005-2007 Sam Stephenson
var undHash = /_|-/,
colons = /\=\=/,
words = /([A-Z]+)([A-Z][a-z])/g,
lowUp = /([a-z\d])([A-Z])/g,
dash = /([a-z\d])([A-Z])/g,
replacer = /\{([^\}]+)\}/g,
quote = /"/g,
singleQuote = /'/g,
var strUndHash = /_|-/,
strColons = /\=\=/,
strWords = /([A-Z]+)([A-Z][a-z])/g,
strLowUp = /([a-z\d])([A-Z])/g,
strDash = /([a-z\d])([A-Z])/g,
strReplacer = /\{([^\}]+)\}/g,
strQuote = /"/g,
strSingleQuote = /'/g,

// Returns the `prop` property from `obj`.
// If `add` is true and `prop` doesn't exist in `obj`, create it as an
Expand Down Expand Up @@ -45,8 +45,8 @@ steal('can/util',function(can) {
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(quote, '&#34;')
.replace(singleQuote, "&#39;");
.replace(strQuote, '&#34;')
.replace(strSingleQuote, "&#39;");
},

/**
Expand Down Expand Up @@ -142,10 +142,10 @@ steal('can/util',function(can) {
*/
underscore: function( s ) {
return s
.replace(colons, '/')
.replace(words, '$1_$2')
.replace(lowUp, '$1_$2')
.replace(dash, '_')
.replace(strColons, '/')
.replace(strWords, '$1_$2')
.replace(strLowUp, '$1_$2')
.replace(strDash, '_')
.toLowerCase();
},
// Micro-templating.
Expand All @@ -167,7 +167,7 @@ steal('can/util',function(can) {
sub: function( str, data, remove ) {
var obs = [];

obs.push( str.replace( replacer, function( whole, inside ) {
obs.push( str.replace( strReplacer, function( whole, inside ) {

// Convert inside to type.
var ob = can.getObject( inside, data, remove === undefined? remove : !remove );
Expand All @@ -191,8 +191,8 @@ steal('can/util',function(can) {

// These regex's are used throughout the rest of can, so let's make
// them available.
replacer : replacer,
undHash : undHash
replacer : strReplacer,
undHash : strUndHash
});
return can;
});

0 comments on commit 652043b

Please sign in to comment.