Skip to content

Commit 65ac9cd

Browse files
committed
feat(tag): add debugger tag
1 parent 34a4bcc commit 65ac9cd

File tree

4 files changed

+77
-11
lines changed

4 files changed

+77
-11
lines changed

examples/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path')
44
const edge = require('../index')
55
const viewsPath = path.join(__dirname, '/views')
66
edge.registerViews(viewsPath)
7-
edge.configure({cache: true})
7+
edge.configure({cache: false})
88
edge.registerPresenters(path.join(__dirname, '/presenters'))
99

1010
require('http').createServer((req, res) => {

src/Tags/Debugger.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
'use strict'
2+
3+
/*
4+
* edge
5+
*
6+
* (c) Harminder Virk <virk@adonisjs.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
const BaseTag = require('./BaseTag')
13+
14+
/**
15+
* The debugger tag for runtime debugging
16+
* inside chrome dev tools.
17+
*
18+
* @class DebuggerTag
19+
* @extends {BaseTag}
20+
* @static
21+
*/
22+
class DebuggerTag extends BaseTag {
23+
/**
24+
* Tag name to be used for registering
25+
* the tag
26+
*
27+
* @method tagName
28+
*
29+
* @return {String}
30+
*/
31+
get tagName () {
32+
return 'debugger'
33+
}
34+
35+
/**
36+
* Whether or not the tag is block level
37+
* tag. Which is no in this case.
38+
*
39+
* @method isBlock
40+
*
41+
* @return {Boolean}
42+
*/
43+
get isBlock () {
44+
return false
45+
}
46+
47+
/**
48+
* Compile the template
49+
*
50+
* @method compile
51+
*
52+
* @param {Object} compiler
53+
* @param {Object} lexer
54+
* @param {Object} buffer
55+
* @param {String} options.body
56+
* @param {Array} options.childs
57+
* @param {Number} options.lineno
58+
*
59+
* @return {void}
60+
*/
61+
compile (compiler, lexer, buffer, { body, childs, lineno }) {
62+
buffer.writeLine('debugger')
63+
}
64+
65+
/**
66+
* Nothing needs to be done in runtime
67+
* for debugger tag
68+
*/
69+
run () {
70+
}
71+
}
72+
73+
module.exports = DebuggerTag

src/Tags/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ module.exports = {
1818
componentTag: new (require('./ComponentTag'))(),
1919
slotTag: new (require('./SlotTag'))(),
2020
sectionTag: new (require('./SectionTag'))(),
21-
yieldTag: new (require('./YieldTag'))()
21+
yieldTag: new (require('./YieldTag'))(),
22+
debugger: new (require('./Debugger'))()
2223
}

src/Template/Compiler.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,7 @@ class TemplateCompiler {
167167
* @return {void}
168168
*/
169169
parsePlainLine ({ body, lineno }) {
170-
/**
171-
* Adding support of debugger to do runtime debugging
172-
* of templates via chrome dev tools.
173-
*/
174-
if (body.trim() === '@debugger') {
175-
this.buffer.writeLine('debugger')
176-
} else {
177-
this.buffer.writeToOutput(this._interpolateMustache(body, lineno))
178-
}
170+
this.buffer.writeToOutput(this._interpolateMustache(body, lineno))
179171
}
180172

181173
/**

0 commit comments

Comments
 (0)