-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification on valid partial identifiers #1230
Comments
I wondered the same thing and found that the spec contains tests that cover slashes and dots in partial names: https://github.com/wycats/handlebars.js/blob/94419deb95c0c8d1edc860026a159139e4800cf6/spec/partials.js#L133-L145 |
The handling of |
Closing due to inactivity. |
Heya Team,
I'm seeking clarification on a few edge cases regarding the naming of partials.
context
My team has been developing a system for
npm
-installing modules that contain handlebars templates (among other things). We publish using a private (scoped) package namespace (call it@rmn
for argument's sake 😉 ).Partials are named according to their directory structure. We have a spec that defines this structure and a suite of tools used for loading handlebars partials that are bundled up according to the spec (express middleware, a
partialresolver
for our php stack using LightnCandy, etc).Partial names are formed by prefixing the relative path to the directory containing the partial with the package name. This is best explained using an example.
example
Given a package named
@rmn/homepage
that provides two partials,button
andcard
, the following is installed innode_modules
:Loading this package will result in 2 partials available for inclusion in a template:
@rmn/homepage/button
@rmn/homepage/card
The nested
@rmn/
+homepage
directory structure is an artifact ofnpm
and the way it installs scoped packages on disk.Up until this point, we've had no trouble using this naming convention (actually, we've enjoyed a lot of success!), but now we are running into issues with other handlebars libraries handling the
@rmn/
prefix (namely LightnCandy).I'm here to seek clarification on what is and what is not allowed in a partial name.
partial naming rules
Directly from the grammar at the time of writing:
Compilers class was a dark time in my life. My primitive understanding of this file leads me to believe the following:
ID
refers to a partial name (eg: the thing used when one invokes a partial,{{> thisIsTheID}}
).ID
can start with any character except those in the negated character class.ID
can not start with@
.but it works
The behavior that I see (and have been seeing across both handlebars.js & LnC for many versions) fails these assertions.
Until that second use case cropped up (recently), where my team started using partial blocks, everything was kosher in both handlebars.js & LnC.
Given that using
@rmn/foo
now fails in LnC, I started digging into the spec and have finally arrived here. We need our templates to be portable and that has led me to the following observations:questions
@rmn/foo
)?{{> "@rmn/foo"}}
Thanks for taking the time to give this issue a read.
The text was updated successfully, but these errors were encountered: