Skip to content

Commit

Permalink
feat(layout): implement layouts in the compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 12, 2018
2 parents 4894f4a + e350e47 commit 73d0b39
Show file tree
Hide file tree
Showing 48 changed files with 448 additions and 58 deletions.
12 changes: 12 additions & 0 deletions fixtures/layout-allow-set-calls/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function (template, ctx) {
let out = ''
ctx.set('username', 'virk')
out += 'This is the base template'
out += '\n'
out += ''
out += '\n'
out += 'Hello '
out += `${ctx.escape(ctx.resolve('username'))}`
out += '\n'
return out
})(template, ctx)
2 changes: 2 additions & 0 deletions fixtures/layout-allow-set-calls/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@layout('layout-allow-set-calls/master')
@set('username', 'virk')
2 changes: 2 additions & 0 deletions fixtures/layout-allow-set-calls/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
3 changes: 3 additions & 0 deletions fixtures/layout-allow-set-calls/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the base template

Hello virk
5 changes: 5 additions & 0 deletions fixtures/layout-allow-set-calls/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the base template

@section('content')
Hello {{ username }}
@endsection
12 changes: 12 additions & 0 deletions fixtures/layout-nested/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function (template, ctx) {
let out = ''
out += 'I will define the header myself'
out += '\n'
out += ''
out += '\n'
out += 'Content from super'
out += '\n'
out += 'Appended by index'
out += '\n'
return out
})(template, ctx)
6 changes: 6 additions & 0 deletions fixtures/layout-nested/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@layout('layout-nested/master')

@section('content')
@super
Appended by index
@endsection
3 changes: 3 additions & 0 deletions fixtures/layout-nested/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
4 changes: 4 additions & 0 deletions fixtures/layout-nested/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
I will define the header myself

Content from super
Appended by index
5 changes: 5 additions & 0 deletions fixtures/layout-nested/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@layout('layout-nested/super')

@section('header')
I will define the header myself
@endsection
5 changes: 5 additions & 0 deletions fixtures/layout-nested/super.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@!section('header')

@section('content')
Content from super
@endsection
12 changes: 12 additions & 0 deletions fixtures/layout-tag-extend-section/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function (template, ctx) {
let out = ''
out += 'This is the base template'
out += '\n'
out += ''
out += '\n'
out += 'Here goes the content section content'
out += '\n'
out += 'I will extend the content of my parent'
out += '\n'
return out
})(template, ctx)
6 changes: 6 additions & 0 deletions fixtures/layout-tag-extend-section/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@layout('layout-tag-extend-section/master')

@section('content')
@super
I will extend the content of my parent
@endsection
3 changes: 3 additions & 0 deletions fixtures/layout-tag-extend-section/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
4 changes: 4 additions & 0 deletions fixtures/layout-tag-extend-section/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is the base template

Here goes the content section content
I will extend the content of my parent
5 changes: 5 additions & 0 deletions fixtures/layout-tag-extend-section/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the base template

@section('content')
Here goes the content section content
@endsection
14 changes: 14 additions & 0 deletions fixtures/layout-tag-multiple-sections/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function (template, ctx) {
let out = ''
out += 'This is the base template'
out += '\n'
out += ''
out += '\n'
out += 'Also the header'
out += '\n'
out += ''
out += '\n'
out += 'I will override the content'
out += '\n'
return out
})(template, ctx)
9 changes: 9 additions & 0 deletions fixtures/layout-tag-multiple-sections/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@layout('layout-tag-multiple-sections/master')

@section('content')
I will override the content
@endsection

@section('header')
Also the header
@endsection
3 changes: 3 additions & 0 deletions fixtures/layout-tag-multiple-sections/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
5 changes: 5 additions & 0 deletions fixtures/layout-tag-multiple-sections/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the base template

Also the header

I will override the content
9 changes: 9 additions & 0 deletions fixtures/layout-tag-multiple-sections/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This is the base template

@section('header')
Here's the header
@endsection

@section('content')
Here goes the content section content
@endsection
10 changes: 10 additions & 0 deletions fixtures/layout-tag-override-sections/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function (template, ctx) {
let out = ''
out += 'This is the base template'
out += '\n'
out += ''
out += '\n'
out += 'I will override the base content'
out += '\n'
return out
})(template, ctx)
5 changes: 5 additions & 0 deletions fixtures/layout-tag-override-sections/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@layout('layout-tag-override-sections/master')

@section('content')
I will override the base content
@endsection
3 changes: 3 additions & 0 deletions fixtures/layout-tag-override-sections/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
3 changes: 3 additions & 0 deletions fixtures/layout-tag-override-sections/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the base template

I will override the base content
5 changes: 5 additions & 0 deletions fixtures/layout-tag-override-sections/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the base template

@section('content')
Here goes the content section content
@endsection
10 changes: 10 additions & 0 deletions fixtures/layout-tag-sections/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function (template, ctx) {
let out = ''
out += 'This is the base template'
out += '\n'
out += ''
out += '\n'
out += 'Here goes the content section content'
out += '\n'
return out
})(template, ctx)
1 change: 1 addition & 0 deletions fixtures/layout-tag-sections/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@layout('layout-tag-sections/master')
3 changes: 3 additions & 0 deletions fixtures/layout-tag-sections/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
3 changes: 3 additions & 0 deletions fixtures/layout-tag-sections/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the base template

Here goes the content section content
5 changes: 5 additions & 0 deletions fixtures/layout-tag-sections/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the base template

@section('content')
Here goes the content section content
@endsection
6 changes: 6 additions & 0 deletions fixtures/layout-tag/compiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function (template, ctx) {
let out = ''
out += 'This is the base template'
out += '\n'
return out
})(template, ctx)
1 change: 1 addition & 0 deletions fixtures/layout-tag/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@layout('layout-tag/master')
3 changes: 3 additions & 0 deletions fixtures/layout-tag/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"username": "virk"
}
1 change: 1 addition & 0 deletions fixtures/layout-tag/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the base template
1 change: 1 addition & 0 deletions fixtures/layout-tag/master.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the base template
28 changes: 17 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"edge-error": "^1.0.0",
"edge-parser": "^1.0.15",
"edge-parser": "^1.0.16",
"he": "^1.1.1",
"lodash": "^4.17.10",
"macroable": "^1.0.0",
Expand Down
Loading

0 comments on commit 73d0b39

Please sign in to comment.