diff --git a/examples/http.js b/examples/http.js index c9be39b..e418056 100644 --- a/examples/http.js +++ b/examples/http.js @@ -4,7 +4,7 @@ const path = require('path') const edge = require('../index') const viewsPath = path.join(__dirname, '/views') edge.registerViews(viewsPath) -edge.configure({cache: true}) +edge.configure({cache: false}) edge.registerPresenters(path.join(__dirname, '/presenters')) require('http').createServer((req, res) => { diff --git a/src/Tags/Debugger.js b/src/Tags/Debugger.js new file mode 100644 index 0000000..7f44607 --- /dev/null +++ b/src/Tags/Debugger.js @@ -0,0 +1,73 @@ +'use strict' + +/* + * edge + * + * (c) Harminder Virk + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. +*/ + +const BaseTag = require('./BaseTag') + +/** + * The debugger tag for runtime debugging + * inside chrome dev tools. + * + * @class DebuggerTag + * @extends {BaseTag} + * @static + */ +class DebuggerTag extends BaseTag { + /** + * Tag name to be used for registering + * the tag + * + * @method tagName + * + * @return {String} + */ + get tagName () { + return 'debugger' + } + + /** + * Whether or not the tag is block level + * tag. Which is no in this case. + * + * @method isBlock + * + * @return {Boolean} + */ + get isBlock () { + return false + } + + /** + * Compile the template + * + * @method compile + * + * @param {Object} compiler + * @param {Object} lexer + * @param {Object} buffer + * @param {String} options.body + * @param {Array} options.childs + * @param {Number} options.lineno + * + * @return {void} + */ + compile (compiler, lexer, buffer, { body, childs, lineno }) { + buffer.writeLine('debugger') + } + + /** + * Nothing needs to be done in runtime + * for debugger tag + */ + run () { + } +} + +module.exports = DebuggerTag diff --git a/src/Tags/index.js b/src/Tags/index.js index dd25a2f..004579d 100644 --- a/src/Tags/index.js +++ b/src/Tags/index.js @@ -18,5 +18,6 @@ module.exports = { componentTag: new (require('./ComponentTag'))(), slotTag: new (require('./SlotTag'))(), sectionTag: new (require('./SectionTag'))(), - yieldTag: new (require('./YieldTag'))() + yieldTag: new (require('./YieldTag'))(), + debugger: new (require('./Debugger'))() } diff --git a/src/Template/Compiler.js b/src/Template/Compiler.js index f18e122..7ea53a1 100644 --- a/src/Template/Compiler.js +++ b/src/Template/Compiler.js @@ -167,15 +167,7 @@ class TemplateCompiler { * @return {void} */ parsePlainLine ({ body, lineno }) { - /** - * Adding support of debugger to do runtime debugging - * of templates via chrome dev tools. - */ - if (body.trim() === '@debugger') { - this.buffer.writeLine('debugger') - } else { - this.buffer.writeToOutput(this._interpolateMustache(body, lineno)) - } + this.buffer.writeToOutput(this._interpolateMustache(body, lineno)) } /**