Question

Apparently you can reference a partial with Spark view engine as a tag with the same name as the partial e.g: <myPartialName /> instead of using <render partial="myPartialName" />

That is great, but how do you reference the partial if it is in a sub folder? e.g. <render partial="partials/myPartialName" />

Anyone know if there is a way to deal with this?

UPDATE

After reading the documentation on organising content, I saw the following paragraph which explained why the above was not working:

Implicit partial rendering

Finally, if your partial file starts with an underscore character the rest of the file name can be used as a new special element. This is nothing more than being used as a shortcut for but it sure looks cool.

I.e. you must append an underscore to a partial name if you want to use implicit rendering, as mentioned in the answer by lomaxx below. So to use the tag <myPartialName/> the actual partial file would have to be _myPartialName.spark.

Was it helpful?

Solution

The issue is that if you have a partial named _myPartialName (note the underscore) in your subfolder, then you need to reference the name explicitly as the shortcuts don't handle the underscore in subfolders properly. So you need to explicitly include the underscore like so:

<render partial="partials/_myPartialName" />

Or you can just change the partial name and remove the underscore

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top