grammarly/rocker

Custom helpers

Closed this issue · 3 comments

Hi guys,

I have a question re the possibility to extend Rocker's template helpers with custom ones, defined locally. Is there a way to do such thing?

What I would like to do is something like this:

Take this imaginary Rockerfile:

FROM alpine:latest

{{ useLocalAlpineMirror }}
RUN apk add --no-cache bash
# ...

useLocalAlpineMirror would be a custom helper that would output a series of Rocker directives that will end up configuring the image so that it uses a local alpine mirror.

Are these "custom helpers" possible? If so, how can I define them?

Thanks for sharing Rocker!

Hi guys, I don't mean to be pushy, but could you help us with this whenever you got the time?

Thanks!

rodio commented

Hi, @ncuesta!

I think it is not possible for now.

It would be great to understand your use case in more detail, but if you need these custom helpers to avoid duplication in your Rockerfiles, please consider Go's text/template {{ define }} action. See example here. I haven't tried it yet but since Rocker's templating is build on top of go's text/template, it should work.

Sorry for the late answer. Thanks!

Hi @rodio! I'll give that a try, but the main use case would be what you considered: avoiding duplication.

Thanks again!