Middleman has few options for customize pathes to images, styles and js scripts:
But what if I want to register custom path (for videos or documents for example) with ability to have :relative_assets routings?
Is it possible to register custom pathes or it is better to use helpers for such a feature?
Probably better to use a helper. It's not well documented, but you can "register" your own asset_url method which is what image_tag and other asset helpers use to find files. This method acts as a stack so you could register your handler at the first position and then the other handlers should run after (adding cache busting, relative paths, etc).
Here's an example:
class << self
app.send :include, InstanceMethods
alias :included :registered
def asset_url(path, prefix="")
if prefix == "video"
# Do something fancy
# super (get the results of higher up the stack, may not be necessary)
asset_path :video, my_video
tag(:video, :src => video_path(my_video))
can u plz post an example of how to actually use this helper in code?
Would it be something like <?= video_tag('relative/path/to/video) ?> ?
<?= video_tag('relative/path/to/video) ?>
<%=, but yeah, exactly like that.
sorry, too much PHP lately