Skip to content

How do I get file path with Handlebars templates? #70

@simzikov

Description

@simzikov

I am using Webpack and Handlebars templates:

index.html

{{> head.html}}

head.html

<link rel="stylesheet" href="./style.css" />
<title>...</title>

Works like a charm. Now I've added a folder next to index.html:

/index.html
/docs/index.html

Both file import the same head.html. However, the one from the docs folder will have an error in the console because the stylehsheet is not loaded. I could have solved this by passing another variable to it, e.g.:

{{> head.html webRoot="."}}

and

{{> head.html webRoot=".."}}

and change head.html to:

<link rel="stylesheet" href="{{webRoot}}/style.css" />
<title>...</title>

However, I hope to think Handlebars has some built-in variable for that. Is there any?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionquestioning about a functionality or usage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions