Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary: Use the rule memory to determine the (basic) path for an item rep, to prepare for adding a
#write
instruction to compilation rules.Current approach
The item reps get their paths (per snapshot) in the
ItemRepRouter
. The item rep router finds the appropriate routing rule, and assigns the raw path (e.g.output/index.html
), along with the path usable for linking (e.g./
).The rule memory calculator compiles the item with a “recording executor”, which does nothing but record filter/layout/… invocations.
New approach
The rule memory calculator will determine the (basic) path for an item rep. It will do so by finding the appropriate routing rule for that item and creating an appropriate
#snapshot
rule action that includes the path of the item rep.The item rep router is still responsible for converting this basic path (e.g.
/foo/index.html
into the path for writing to (output/foo/index.html
) and the path for linking to (/foo/
).This makes it possible to add a
:path
argument to#snapshot
in rules, so you can now write files from within the compilation rule. For example:… as opposed to this:
Having to specify a snapshot is annoying, so there will be a convenience method
#write
:This approach also helps pushing the rules further away from the core of Nanoc, and the rule memory might become a “processing instruction list”, which could become what Nanoc uses to determine how to process an item rep. With that in place, Nanoc could gain alternatives to the Rules file as a processing instruction source.