1 | cc = require '../lib/coffeecup'
|
2 |
|
3 | describe 'Attributes', ->
|
4 | describe "a href: '/', title: 'Home'", ->
|
5 | it 'should render <a href="/" title="Home"></a>', ->
|
6 | a = -> a href: '/', title: 'Home'
|
7 | cc.render(a).should.equal '<a href="/" title="Home"></a>'
|
8 |
|
9 | describe 'Attribute values', ->
|
10 | describe "br vrai: yes, faux: no, undef: @foo, nil: null, str: 'str', num: 42, arr: [1, 2, 3], obj: {foo: 'bar'}, func: ->", ->
|
11 | it 'should render <br vrai="vrai" str="str" num="42" arr="1,2,3" obj-foo="bar" func="(function () {}).call(this);" />', ->
|
12 | a = -> br vrai: yes, faux: no, undef: @foo, nil: null, str: 'str', num: 42, arr: [1, 2, 3], obj: {foo: 'bar'}, func: ->
|
13 | cc.render(a).should.equal '<br vrai="vrai" str="str" num="42" arr="1,2,3" obj-foo="bar" func="(function () {}).call(this);" />'
|
14 |
|
15 | describe 'Inline attributes', ->
|
16 | describe "p '#foo {{bindAttr class=isSelected}}, 'Bar'", ->
|
17 | a = -> p '#foo {{bindAttr class="isSelected"}}', 'Bar'
|
18 | cc.render(a).should.equal '<p id="foo" {{bindAttr class="isSelected"}}>Bar</p>'
|
19 |
|
20 | describe "p '{{bindAttr class=isActive target=App}}, 'Bar'", ->
|
21 | a = -> p '{{bindAttr class="isActive" target="App"}}', 'Bar'
|
22 | cc.render(a).should.equal '<p {{bindAttr class="isActive" target="App"}}>Bar</p>'
|
23 |
|
24 | describe 'Attributes optimized', ->
|
25 | describe "a href: '/', title: 'Home'", ->
|
26 | it 'should render <a href="/" title="Home"></a>', ->
|
27 | a = -> a href: '/', title: 'Home'
|
28 | cc.render(a, optimize: true, cache: on).should.equal '<a href="/" title="Home"></a>'
|
29 |
|
30 | describe 'Attribute values optimized', ->
|
31 | describe "br vrai: yes, faux: no, undef: @foo, nil: null, str: 'str', num: 42, arr: [1, 2, 3], obj: {foo: 'bar'}, func: ->", ->
|
32 | it 'should render <br vrai="vrai" str="str" num="42" arr="1,2,3" obj-foo="bar" func="(function () {}).call(this);" />', ->
|
33 | a = -> br vrai: yes, faux: no, undef: @foo, nil: null, str: 'str', num: 42, arr: [1, 2, 3], obj: {foo: 'bar'}, func: ->
|
34 | cc.render(a, optimize: true).should.equal '<br vrai="vrai" str="str" num="42" arr="1,2,3" obj-foo="bar" func="(function () {}).call(this);" />'
|