Skip to content

Commit

Permalink
exposed toHex and toUnicode in case they might be useful.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanema committed Jul 13, 2011
1 parent e2e9da9 commit c5b67bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -87,11 +87,12 @@ doctype that are define are:
* XHTML1f
* XHTML1_1


doctype_tag(HTML4s) =>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
doctype_tag() =>
<!DOCTYPE HTML>
doctype_tag() =>
<!DOCTYPE HTML>

### date_tag(name, [value, html_options])
Creates a date tag
Expand Down
36 changes: 18 additions & 18 deletions lib/express-helpers.js
Expand Up @@ -260,7 +260,7 @@ module.exports = function(app) {
return txt;
};

var single_tag_for = helpers.single_tag_for = function(_tag, html_options) { return tag(_tag, html_options, false);};
var single_tag_for = helpers.single_tag_for = function(_tag, html_options) { return tag(_tag, html_options, true);};
var start_tag_for = helpers.start_tag_for = function(_tag, html_options) { return tag(_tag, html_options); };

helpers.submit_tag = function(idfor) {
Expand Down Expand Up @@ -289,22 +289,22 @@ module.exports = function(app) {
return single_tag_for('input', html_options);
};

var tag = helpers.tag = function(_tag, html_options, open) {
open = open || true
var txt = ' ';
for (var attr in html_options) {
if (html_options[attr] != null)
var value = html_options[attr].toString();
var tag = helpers.tag = function(_tag, html_options, closed) {
closed = closed || false
var txt = ' ';
for (var attr in html_options) {
if (html_options[attr] != null)
var value = html_options[attr].toString();
else
var value='';
if (attr == "Class") // special case because "class" is a reserved word in IE
attr = "class";
if (value.indexOf("'") != -1)
txt += attr+'=\"'+value+'\" ';
else
txt += attr+"='"+value+"' ";
}
return '<'+_tag+txt+(open ? '>' : '/>');
var value='';
if (attr == "Class") // special case because "class" is a reserved word in IE
attr = "class";
if (value.indexOf("'") != -1)
txt += attr+'=\"'+value+'\" ';
else
txt += attr+"='"+value+"' ";
}
return '<'+_tag+txt+(closed ? '/>' : '>');
};

var end_tag = helpers.end_tag = function(_tag) { return '</'+_tag+'>'; };
Expand Down Expand Up @@ -359,14 +359,14 @@ module.exports = function(app) {
return "<![CDATA["+content+"]]>"
}

function convertToUnicode(source) {
var convertToUnicode = helpers.toUnicode = function(source) {
result = '';
for (i=0; i<source.length; i++)
result += '&#' + source.charCodeAt(i) + ';';
return result;
}

function convertToHexadecimal(num) {
var convertToHexadecimal = helpers.toHex = function(num) {
var hex = '';
for (i=0;i<num.length;i++)
hex += "%" + num.charCodeAt(i).toString(16).toUpperCase();
Expand Down

0 comments on commit c5b67bb

Please sign in to comment.