Merge branch 'master' into editor

This commit is contained in:
Danny Greg & Nathan Sobo
2012-01-19 16:47:12 -08:00
3 changed files with 18 additions and 7 deletions

View File

@@ -44,6 +44,11 @@ describe "Builder", ->
builder.tag 'br', id: 'foo'
expect(builder.toHtml()).toBe '<br id="foo">'
describe ".raw(text)", ->
it "does not escape html entities", ->
builder.raw '&nbsp;'
expect(builder.toHtml()).toBe '&nbsp;'
describe ".subview(name, template, attrs)", ->
template = null

View File

@@ -66,6 +66,9 @@ class Builder
text: (string) ->
@document.push(new Text(string))
raw: (string) ->
@document.push(new Text(string, true))
wireOutlets: (view) ->
view.find('[outlet]').each ->
elt = $(this)

View File

@@ -1,12 +1,15 @@
module.exports =
class Text
constructor: (@string) ->
constructor: (@string, @raw=false) ->
toHtml: ->
@string
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
if @raw
@string
else
@string
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')