jbake
jbake copied to clipboard
Access to assets from template
As far as I can see, there is currently not a general way to get access to a list of available assets or check for existence of a specific asset (for example an image) from the templates. I think it is not in the scope of the templating engine to provide such mechanism, as in a webserver environment, models and variables are provided by the web server to the templates, but in a static site generator, it should be the responsibility of the site generator to provide it.
Would access to a collection of file references (i.e. the assets crawled) be sufficient? As this should be fairly straight forward to expose to the template engines via the data model.
Extending to what @jonbullock said, Should that be a list of every non-content files discovered by the engine? For example, asset
collection to use similar to alltags
data model that contains list of tag string names. The collection may just contain a relative path of an discovered asset like [/resources/img/abc.png
, /resource/css/abc.css
]. Templates can then check if path exists in the collection.
Hmm. It should be possible to bind an object to the model. So that we could use something like
meta.getAssets()
meta.findAssetByName('monkey.jpg')
meta.getCurrentTime()
etc.
I like the idea of an object API being exposed, saves the end users from re-implementing the same logic over and over in the template engines.