Skip to content

Commit 6888d3a

Browse files
authored
Merge pull request #2 from admin-ch/helper-context
Ensure helper body gets the right context when compiled with Handlebars & Lodash
2 parents e2cf9a1 + 558799d commit 6888d3a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function markdown(config) {
4040
}
4141

4242
var md = new Remarkable(options);
43-
var ctx = merge({}, options, this.context, context);
43+
var ctx = merge({}, options, this, this.context, context);
4444
return md.render(options.fn(ctx));
4545
}
4646

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('sync', function() {
5050
describe('handlebars:', function() {
5151
it('should work as a handlebars helper:', function() {
5252
handlebars.registerHelper('markdown', markdown({highlight: highlight}));
53-
handlebars.compile('{{#markdown}}# heading{{/markdown}}')().should.equal('<h1>heading</h1>\n');
53+
handlebars.compile('{{#markdown}}# {{title}}{{/markdown}}')({title: 'heading'}).should.equal('<h1>heading</h1>\n');
5454
});
5555

5656
it('should pass hash options to remarkable:', function() {
@@ -81,7 +81,7 @@ describe('sync', function() {
8181
describe('lodash:', function() {
8282
it('should work as a lodash mixin:', function() {
8383
_.mixin({markdown: markdown});
84-
_.template('<%= _.markdown("# heading") %>')({}).should.equal('<h1>heading</h1>\n');
84+
_.template('<%= _.markdown("# " + title) %>')({title: 'heading'}).should.equal('<h1>heading</h1>\n');
8585
});
8686

8787
it('should pass options to remarkable:', function() {

0 commit comments

Comments
 (0)