question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md helper exports async by default

See original GitHub issue

Hi,

I’m using gulp with assemble 0.17.1 and handlebars-helpers 0.7.7 and the md helper isn’t working. We’re loading the helper module as described in the readme and other helpers are working (e.g. markdown, isnt, foreach).

Usage within the templates is as described in the docs:

{{md 'path/to/md/file.md'}}

The error message i get is: Error: md async helper expects callback to be a function. Did you mean to use md.sync?

I’m migrating a site from a very old grunt version of assemble and it uses the md helper quite heavily so I’m keen to get this working. I’ve managed to bodge around it for now by overriding the md helper, but it’s a bit of a bodge and it’d be great if it could work without this 😃

`app.helper(‘md’, function (fpath) {

	var fs = require('fs'),
		path = require('path'),
		content = fs.readFileSync(fpath, 'utf8'),
		Remarkable = require('remarkable');

	var markd = new Remarkable({
		html: 		true,
		xhtmlOut: 	false,
		breaks: 	true
	});

	return markd.render(content);

});`

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
blueowl0708commented, Jan 13, 2017

@jonschlinkert - title updated, hope this is sufficient… change it to something more appropriate if not 😃

Thanks to both you and @doowb for the extremely quick response to this!

1reaction
jonschlinkertcommented, Jan 13, 2017

hmm, I didn’t realize (or remember) that the md helper was exporting the async version by default. In handlebars-helpers we should just wrap it and return the sync function to avoid this issue.

@blueowl0708 would you mind creating an issue on handlebars-helpers regarding exporting the sync function? If not I’ll be back from codemash this weekend and can work on it then, thanks

edit: lol I clicked on this from a link on my phone. since the title said “assemble” I thought it was on assemble. anyway, we can change the title of this issue I think. However, it might be better to do what @doowb mentioned, but try also doing:

app.asyncHelper('md', helpers.md);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Misleading error that module does not provide export #32137
import { default as md } from '../lib/index.js'; console.log(md);. So your importing the default export (the module.exports object) from .
Read more >
await is only valid in async function - Stack Overflow
await can only be used to CALL async functions. await can appear in any kind of function, synchronous or asynchronous. Change the error...
Read more >
ES6 async/await | Developer Guide - Nightwatch.js
The async function enables the API commands to return a promise and makes it possible to use the await operator to retrieve the...
Read more >
Configuration — Eleventy
module.exports = function(eleventyConfig) { ... Default, html,liquid,ejs,md,hbs,mustache,haml,pug,njk,11ty.js ... Can be sync or async eleventyConfig.
Read more >
Creating Objectives | TwilioQuest Extensions
description.md,; example.js,; objective.json,; validator.js, ... module.exports = async function (helper) { let context; try { context = await helper.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found