lazd / lazd/gulp-handlebars

From require to import!?

Open
#109 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
169
Forks
73
PR merge metrics
No merged PRs in 30d

Description

I'm forced to use Handlebars as an import due to module types changing from CommonJS to ES types all over the place.

I used to do this in Gulp, and read along the way that I had to use it like this ( *requiring it in the proces* ):
```
const gulp_handlebars = require('gulp-handlebars');
...
.pipe( gulp_handlebars({
handlebars: require('handlebars)
}))
...
```

But, now I have to do it like this:
```
import Handlebars from 'handlebars';
...
.pipe( gulp_handlebars({
handlebars: Handlebars
}))
...
```

It's used to precompile templates and partials that is further piped like this:

```
.pipe( wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
imports: {
processPartialName: function(fileName) {
// Strip the extension and the underscore
// Escape the output with JSON.stringify
return JSON.stringify( path.basename( fileName, '.js' ).substr(1) );
}
}
})
```
And this means that 'Handlebars' (of course) now work in a complete different way – no longer generating ANY templates.

WHAT do I have to change to get the 'old' behaviour back?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown require/import setup in the gulp_handlebars pipeline, focusing on the handlebars option and the precompile and partial-registration steps. Compare the generated templates with the old behavior; done means templates and partials are generated and registered as before.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, javascript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.