()
| 3359 | |
| 3360 | |
| 3361 | function simpleWriter() { |
| 3362 | var fragments = []; |
| 3363 | |
| 3364 | function open(tagName, attributes) { |
| 3365 | var attributeString = generateAttributeString(attributes); |
| 3366 | fragments.push(util.format("<%s%s>", tagName, attributeString)); |
| 3367 | } |
| 3368 | |
| 3369 | function close(tagName) { |
| 3370 | fragments.push(util.format("</%s>", tagName)); |
| 3371 | } |
| 3372 | |
| 3373 | function selfClosing(tagName, attributes) { |
| 3374 | var attributeString = generateAttributeString(attributes); |
| 3375 | fragments.push(util.format("<%s%s />", tagName, attributeString)); |
| 3376 | } |
| 3377 | |
| 3378 | function generateAttributeString(attributes) { |
| 3379 | return _.map(attributes, function(value, key) { |
| 3380 | return util.format(' %s="%s"', key, escapeHtmlAttribute(value)); |
| 3381 | }).join(""); |
| 3382 | } |
| 3383 | |
| 3384 | function text(value) { |
| 3385 | fragments.push(escapeHtmlText(value)); |
| 3386 | } |
| 3387 | |
| 3388 | function append(html) { |
| 3389 | fragments.push(html); |
| 3390 | } |
| 3391 | |
| 3392 | function asString() { |
| 3393 | return fragments.join(""); |
| 3394 | } |
| 3395 | |
| 3396 | return { |
| 3397 | asString: asString, |
| 3398 | open: open, |
| 3399 | close: close, |
| 3400 | text: text, |
| 3401 | selfClosing: selfClosing, |
| 3402 | _append: append |
| 3403 | }; |
| 3404 | } |
| 3405 | |
| 3406 | function escapeHtmlText(value) { |
| 3407 | return value |
no outgoing calls
no test coverage detected