Skip to content

Commit 475576a

Browse files
committed
WIP
1 parent 81456cb commit 475576a

86 files changed

Lines changed: 8726 additions & 177 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on: [push, pull_request]
33
jobs:
44
test:
55
runs-on: ubuntu-latest
6+
env:
7+
HAML_BENCH_ITERS: 100
68
steps:
79
- uses: actions/checkout@v4
810
- uses: Raku/setup-raku@v1
@@ -23,3 +25,5 @@ jobs:
2325
run: zef install --/test App::Prove6
2426
- name: Run tests
2527
run: ./test.raku
28+
- name: Run benchmarks
29+
run: behave --benchmark specs/bench/

META6.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"auth": "zef:gdonald",
99
"depends": [],
1010
"build-depends": [],
11-
"test-depends": ["Test", "Test::META"],
11+
"test-depends": ["Test", "Test::META", "BDD::Behave"],
1212
"provides": {
1313
"Template::HAML": "lib/Template/HAML.rakumod",
1414
"Template::HAML::Actions": "lib/Template/HAML/Actions.rakumod",

bench/render.raku

Lines changed: 0 additions & 175 deletions
This file was deleted.

specs/attrs/attr-escape-spec.raku

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use lib 'lib';
2+
use BDD::Behave;
3+
use Template::HAML;
4+
5+
describe 'attribute value HTML escaping', {
6+
it 'escapes &', {
7+
expect(HAML.render(:src(Q[%a{title: 'tom & jerry'}] ~ "\n")))
8+
.to.eq("<a title='tom &amp; jerry'></a>\n");
9+
}
10+
11+
it 'escapes < and >', {
12+
expect(HAML.render(:src(Q[%a{title: '<script>'}] ~ "\n")))
13+
.to.eq("<a title='&lt;script&gt;'></a>\n");
14+
}
15+
16+
it 'escapes a single quote to &#39;', {
17+
expect(HAML.render(:src(Q[%a{title: "don't"}] ~ "\n")))
18+
.to.eq("<a title='don&#39;t'></a>\n");
19+
}
20+
21+
it 'escapes a double quote to &quot;', {
22+
expect(HAML.render(:src(Q[%a{title: 'a "quoted" word'}] ~ "\n")))
23+
.to.eq("<a title='a &quot;quoted&quot; word'></a>\n");
24+
}
25+
26+
it 'escapes combined &, <, > in one value', {
27+
expect(HAML.render(:src(Q[%a{title: 'a & b < c'}] ~ "\n")))
28+
.to.eq("<a title='a &amp; b &lt; c'></a>\n");
29+
}
30+
}

specs/attrs/attr-order-spec.raku

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use lib 'lib';
2+
use BDD::Behave;
3+
use Template::HAML;
4+
5+
describe 'attribute emission order', {
6+
it 'emits id and class first, then the rest in insertion order', {
7+
expect(HAML.render(:src(Q<%a{title: 't', class: 'c', id: 'i', href: '/'}> ~ "\n")))
8+
.to.eq("<a id='i' class='c' title='t' href='/'></a>\n");
9+
}
10+
11+
it 'preserves insertion order for plain keys', {
12+
expect(HAML.render(:src(Q<%a{c: 3, a: 1, b: 2}> ~ "\n")))
13+
.to.eq("<a c='3' a='1' b='2'></a>\n");
14+
}
15+
16+
it 'emits shorthand id first even with literal pairs after', {
17+
expect(HAML.render(:src(Q<%a#main{href: '/', class: 'cls'}> ~ "\n")))
18+
.to.eq("<a id='main' class='cls' href='/'></a>\n");
19+
}
20+
21+
it 'emits shorthand class after id and before remaining keys', {
22+
expect(HAML.render(:src(Q<%a.foo{href: '/', id: 'm'}> ~ "\n")))
23+
.to.eq("<a id='m' class='foo' href='/'></a>\n");
24+
}
25+
}

0 commit comments

Comments
 (0)