haml-coffee
Version:
Haml templates where you can write inline CoffeeScript.
47 lines (34 loc) • 1.24 kB
JavaScript
(function() {
var HamlCoffeeHelpers;
HamlCoffeeHelpers = (function() {
function HamlCoffeeHelpers() {}
HamlCoffeeHelpers.prototype.htmlEscape = function(text) {
return ("" + text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\'/g, ''').replace(/\"/g, '"');
};
HamlCoffeeHelpers.prototype.preserve = function(text) {
return text.replace(/\\n/g, '
');
};
HamlCoffeeHelpers.prototype.findAndPreserve = function(text) {
return text.replace(/<(textarea|pre)>([^]*?)<\/\1>/g, function(str, tag, content) {
return "<\#{ tag }>\#{ content.replace /\\n/g, '
' }</\#{ tag }>";
});
};
HamlCoffeeHelpers.prototype.cleanValue = function(value) {
if (value === null || value === void 0) {
return '';
} else {
return value;
}
};
HamlCoffeeHelpers.prototype.surround = function(start, end, fn) {
return start + fn() + end;
};
HamlCoffeeHelpers.prototype.succeed = function(end, fn) {
return fn() + end;
};
HamlCoffeeHelpers.prototype.precede = function(start, fn) {
return start + fn();
};
return HamlCoffeeHelpers;
})();
}).call(this);