aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/html-generator.js11
-rw-r--r--lib/style-reader.js5
-rw-r--r--lib/styles.js11
3 files changed, 11 insertions, 16 deletions
diff --git a/lib/html-generator.js b/lib/html-generator.js
index 065d1d2..179d6d0 100644
--- a/lib/html-generator.js
+++ b/lib/html-generator.js
@@ -79,14 +79,9 @@ function HtmlGenerator() {
function writeElement(stackElement) {
stackElement.written = true;
var element = stackElement.element;
- if (element["class"]) {
- var attributeString = util.format(' %s="%s"', "class", element["class"]);
- } else {
- var attributeString = "";
- }
- if (element.href) {
- attributeString += util.format(' href="%s"', escapeHtml(element.href));
- }
+ var attributeString = _.map(element.attributes, function(value, key) {
+ return util.format(' %s="%s"', key, value);
+ }).join("");
fragments.push(util.format("<%s%s>", element.tagName, attributeString));
}
diff --git a/lib/style-reader.js b/lib/style-reader.js
index a566826..9e23abd 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -33,14 +33,15 @@ function read(string) {
capture(lop.rules.zeroOrMore(classRule)),
capture(freshRule)
).map(function(tagName, classNames, fresh) {
+ var attributes = {};
var options = {};
if (classNames.length > 0) {
- options["class"] = classNames.join(" ");
+ attributes["class"] = classNames.join(" ");
}
if (fresh) {
options["fresh"] = true;
}
- return styles.element(tagName, options);
+ return styles.element(tagName, attributes, options);
});
var styleRule = lop.rules.then(
diff --git a/lib/styles.js b/lib/styles.js
index cbe36d4..737bdcb 100644
--- a/lib/styles.js
+++ b/lib/styles.js
@@ -4,8 +4,8 @@ exports.topLevelElement = topLevelElement;
exports.elements = elements;
exports.element = element;
-function topLevelElement(tagName) {
- return elements([element(tagName, {fresh: true})]);
+function topLevelElement(tagName, attributes) {
+ return elements([element(tagName, attributes, {fresh: true})]);
}
function elements(elementStyles) {
@@ -18,12 +18,11 @@ function elements(elementStyles) {
});
}
-function element(tagName, options) {
+function element(tagName, attributes, options) {
options = options || {};
return {
tagName: tagName,
- fresh: options.fresh,
- "class": options["class"],
- href: options.href
+ attributes: attributes || {},
+ fresh: options.fresh
};
}