From 4f6b2e7977c91d060665ff34b1e51b4a816aa2a8 Mon Sep 17 00:00:00 2001 From: Eric Gjertsen Date: Sun, 30 Mar 2014 12:51:59 -0400 Subject: [PATCH] add shortcode.has() --- lib/shortcode-parser.js | 6 +++++- test/unit.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/shortcode-parser.js b/lib/shortcode-parser.js index 5c6fb2d..db5b7c8 100644 --- a/lib/shortcode-parser.js +++ b/lib/shortcode-parser.js @@ -99,6 +99,10 @@ module.exports = { delete shortcodes[name]; }, + has: function(name){ + return !!shortcodes[name]; + }, + parse: function(buf, extra, context) { context = context || shortcodes; @@ -152,4 +156,4 @@ module.exports = { return this.parse(buf, data, context); } -} \ No newline at end of file +} diff --git a/test/unit.js b/test/unit.js index 85fdcdb..3d4eb2d 100644 --- a/test/unit.js +++ b/test/unit.js @@ -85,6 +85,10 @@ vows.describe("Shortcode Parser").addBatch({ assert.deepEqual(val, shortcode._shortcodes); }, + "Has shortcode handlers": function(val){ + for (var k in val) assert(shortcode.has(k)); + }, + "Removes shortcode handlers": function(val) { var noop = function() {}; shortcode.add('test', noop); @@ -147,4 +151,4 @@ vows.describe("Shortcode Parser").addBatch({ } -}).export(module); \ No newline at end of file +}).export(module);