Permalink
Browse files

Merge pull request #61 from crowdfavorite/expose_helper_functions

Expose helper functions in twttr.txt namespace
  • Loading branch information...
2 parents 66b07dd + 89fcdd1 commit cdedeae8735fb7977a81536038843bcc3a8ac5c8 @keitaf keitaf committed May 18, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 twitter-text.js
View
@@ -53,13 +53,17 @@ if (typeof twttr === "undefined" || twttr === null) {
}), flags);
}
+ twttr.txt.regexSupplant = regexSupplant;
+
// simple string interpolation
function stringSupplant(str, values) {
return str.replace(/#\{(\w+)\}/g, function(match, name) {
return values[name] || "";
});
}
+ twttr.txt.stringSupplant = stringSupplant;
+
function addCharsToCharClass(charClass, start, end) {
var s = String.fromCharCode(start);
if (end !== start) {
@@ -69,6 +73,8 @@ if (typeof twttr === "undefined" || twttr === null) {
return charClass;
}
+ twttr.txt.addCharsToCharClass = addCharsToCharClass;
+
// Space is more than %20, U+3000 for example is the full-width space used with Kanji. Provide a short-hand
// to access both the list of characters and a pattern suitible for use with String#split
// Taken from: ActiveSupport::Multibyte::Handlers::UTF8Handler::UNICODE_WHITESPACE

0 comments on commit cdedeae

Please sign in to comment.