diff --git a/compiler/index.js b/compiler/index.js index 793b25cd7..47a09d87d 100644 --- a/compiler/index.js +++ b/compiler/index.js @@ -127,6 +127,12 @@ function getLastModified(path, options, callback) { callback(null, -1); // TODO Implement getLastModified } +function clearCaches() { + exports.taglibLookup.clearCache(); + exports.taglibFinder.clearCache(); + exports.taglibLoader.clearCache(); +} + exports.createBuilder = createBuilder; exports.compileFile = compileFile; exports.compile = compile; @@ -136,10 +142,12 @@ exports.getLastModified = getLastModified; exports.createWalker = createWalker; exports.builder = Builder.DEFAULT_BUILDER; exports.configure = configure; +exports.clearCaches = clearCaches; var taglibLookup = require('./taglib-lookup'); exports.taglibLookup = taglibLookup; exports.taglibLoader = require('./taglib-loader'); +exports.taglibFinder = require('./taglib-finder'); taglibLookup.registerTaglib(require.resolve('../taglibs/core/marko.json')); taglibLookup.registerTaglib(require.resolve('../taglibs/layout/marko.json')); diff --git a/compiler/taglib-finder/index.js b/compiler/taglib-finder/index.js index 62d04533b..316e3e8b7 100644 --- a/compiler/taglib-finder/index.js +++ b/compiler/taglib-finder/index.js @@ -140,11 +140,11 @@ function find(dirname, registeredTaglibs) { return found; } -function clearCaches() { +function clearCache() { existsCache = {}; findCache = {}; taglibsForNodeModulesDirCache = {}; } exports.find = find; -exports.clearCaches = clearCaches; +exports.clearCache = clearCache; diff --git a/compiler/taglib-loader/index.js b/compiler/taglib-loader/index.js index 3047a1d1a..0c15a20bc 100644 --- a/compiler/taglib-loader/index.js +++ b/compiler/taglib-loader/index.js @@ -35,4 +35,8 @@ function load(path) { return taglib; } +exports.clearCache = function() { + cache = {}; +}; + exports.load = load; diff --git a/compiler/taglib-lookup/index.js b/compiler/taglib-lookup/index.js index 2cc74642f..a93ac1d14 100644 --- a/compiler/taglib-lookup/index.js +++ b/compiler/taglib-lookup/index.js @@ -16,7 +16,7 @@ 'use strict'; exports.registerTaglib = registerTaglib; exports.buildLookup = buildLookup; -exports.clearCaches = clearCaches; +exports.clearCache = clearCache; var taglibLoader = require('../taglib-loader'); var taglibFinder = require('../taglib-finder'); @@ -75,6 +75,6 @@ function registerTaglib(taglib) { exports.registeredTaglibs.push(taglib); } -function clearCaches() { +function clearCache() { lookupCache = {}; } \ No newline at end of file diff --git a/test/fixtures/hot-reload/hot-reload.marko b/test/fixtures/hot-reload/hot-reload.marko new file mode 100644 index 000000000..eabd502aa --- /dev/null +++ b/test/fixtures/hot-reload/hot-reload.marko @@ -0,0 +1 @@ +- Hello ${data.name}! \ No newline at end of file diff --git a/test/hot-reload-test.js b/test/hot-reload-test.js index 1cae06de3..3dab8f051 100644 --- a/test/hot-reload-test.js +++ b/test/hot-reload-test.js @@ -8,7 +8,7 @@ var fs = require('fs'); require('../node-require').install(); -xdescribe('hot-reload' , function() { +describe('hot-reload' , function() { before(function() { require('../hot-reload').enable(); require('../compiler').defaultOptions.checkUpToDate = false; @@ -17,7 +17,7 @@ xdescribe('hot-reload' , function() { it('should allow a required template to be hot reloaded', function() { - var srcTemplatePath = nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'); + var srcTemplatePath = nodePath.join(__dirname, 'fixtures/hot-reload/hot-reload.marko'); var templateSrc = fs.readFileSync(srcTemplatePath, { encoding: 'utf8' }); var tempTemplatePath = nodePath.join(__dirname, 'temp/hello.marko'); @@ -39,7 +39,7 @@ xdescribe('hot-reload' , function() { it('should allow a non-required template to be hot reloaded', function() { - var srcTemplatePath = nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'); + var srcTemplatePath = nodePath.join(__dirname, 'fixtures/hot-reload/hot-reload.marko'); var templateSrc = fs.readFileSync(srcTemplatePath, { encoding: 'utf8' }); var tempTemplatePath = nodePath.join(__dirname, 'temp/hello2.marko'); diff --git a/test/temp/hello.marko.js b/test/temp/hello.marko.js new file mode 100644 index 000000000..60b105712 --- /dev/null +++ b/test/temp/hello.marko.js @@ -0,0 +1,14 @@ +function create(__helpers) { + var str = __helpers.s, + empty = __helpers.e, + notEmpty = __helpers.ne, + escapeXml = __helpers.x; + + return function render(data, out) { + out.w("Hello " + + escapeXml(data.name) + + "!!"); + }; +} + +(module.exports = require("marko").c(__filename)).c(create); diff --git a/test/temp/hello2.marko.js b/test/temp/hello2.marko.js new file mode 100644 index 000000000..60b105712 --- /dev/null +++ b/test/temp/hello2.marko.js @@ -0,0 +1,14 @@ +function create(__helpers) { + var str = __helpers.s, + empty = __helpers.e, + notEmpty = __helpers.ne, + escapeXml = __helpers.x; + + return function render(data, out) { + out.w("Hello " + + escapeXml(data.name) + + "!!"); + }; +} + +(module.exports = require("marko").c(__filename)).c(create);