nanoc / features

Collection of feature requests
2 stars 1 forks source link

Allow referring to compiled content in rule #44

Open denisdefreyne opened 6 years ago

denisdefreyne commented 6 years ago

For cache-busting purposes, it would be useful to write a file to a path that depends on the compiled content:

compile '/style/screen.css' do
  hash = Digest::SHA1.hexdigest(item_rep.compiled_content)
  write "/style/screen-#{hash}.css"
end

This is not currently possible, because there is a chicken-and-egg problem (a rule defines how to compile an item rep, but the rule cannot be applied until after the item rep is compiled) which might only be solvable by putting severe restrictions on where the compiled content can be accessed — ideally, only in #write in a compilation rule.

denisdefreyne commented 6 years ago

Idea from @Fjan:

Perhaps implement it by creating an item_rep.fingerprinted_name so nanoc can keep control where it's being used and prevent people from using compiled content in other places.