sagold / handlebars-webpack-plugin

Renders your html-template at build time
162 stars 45 forks source link

Add ability to parse and convert nested .hbs files #55

Closed maratfakhreev closed 5 years ago

maratfakhreev commented 5 years ago

The reason: Now plugin is parsing only 1st level templates inside directory (plane structure).

My offer: In my project I'm using a lot of nested subdirectories and for this reason I've made customized version of plugin to support it. I think it's very important to add ability to parse nested directories with .hbs templates especially if it doesn't break current API. So now entry: path.join(process.cwd(), "app", "src", "**", "*.hbs") will convert whole tree of files.

davidwieler commented 5 years ago

Is this going to get merged soonish?

sagold commented 5 years ago

Hi @maratfakhreev

I am not quite sure what you are trying to accomplish:

Currently you can use a glob-pattern for the entry option. In my test-branch i use the following options

entry: path.join(process.cwd(), "app", "src", "**", "*.hbs"),
output: path.join(process.cwd(), "build", "[name].html")

to compile all files from

app/src/nested/deeply/deeply-nested.hbs
app/src/nested/nested.hbs
app/src/app.hbs
app/src/index.hbs

which creates the following html files

build/app.html
build/deeply-nested.html
build/index.html
build/nested.html

When switching to your branch, with the same setup, no files are generated.

maratfakhreev commented 5 years ago

Hi @sagold and sorry for the long answer. My goal is to save structure too. I mean for files from:

app/src/nested/deeply/deeply-nested.hbs
app/src/nested/nested.hbs
app/src/app.hbs
app/src/index.hbs

I want to see this output (that saves paths structure):

app/src/nested/deeply/deeply-nested.html
app/src/nested/nested.html
app/src/app.html
app/src/index.html

I've found an issue that provides conflicts and have made a PR #56. Please check it out and let me know if the problem still occurs.