Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make go templating left and right delimiter customizable. #13

Merged
merged 1 commit into from
Feb 20, 2016

Conversation

lalyos
Copy link
Contributor

@lalyos lalyos commented Feb 19, 2016

Lately i tried to generate packer.io files. But packer itself uses go templating.

So you have to replace all {{ with {{"{{"}} and the same goes: }} to {{"}}"}}. It makes the template really hard tpo read. With the propose env variables sigil could use, let's say triple braces to generate files which use go templating:

I'm able to switch on a section with a variable:

SIGIL_LEFT_DELIM={{{ SIGIL_RIGHT_DELIM=}}} sigil -f packer.tmpl atlas=true

or switch off:

SIGIL_LEFT_DELIM={{{ SIGIL_RIGHT_DELIM=}}} sigil -f packer.tmpl atlas=true

content of packer.tmpl:

{
  "variables": {
    "mock": "{{ env `MOCK` }}",

    "aws_access_key": "{{ env `AWS_ACCESS_KEY` }}",
    "aws_secret_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}"
  },

  {{{ with $atlas }}}
  "post-processors": [
    {
      "type": "atlas",
      "artifact": "sequenceiq/{{ user `atlas_artifact` }}",
      "artifact_type": "{{ build_name }}.image"
    }
  ]
  {{{ end }}}
}

@progrium
Copy link
Contributor

Cool. Can we make it a single variable since it's one thing. You'd never just change one of them. Maybe call it SIGIL_DELIMS with a value like {{{,}}}.

@lalyos
Copy link
Contributor Author

lalyos commented Feb 20, 2016

Good point. Just changed it, and added a section to README explaining the reason.

Maybe we can define configuration for separating left and right delims in SIGIL_DELIMS like SIGIL_DELIM_SEPARATOR=,
;)

@progrium
Copy link
Contributor

lol

progrium added a commit that referenced this pull request Feb 20, 2016
Make go templating left and right delimiter customizable.
@progrium progrium merged commit e6c0916 into gliderlabs:master Feb 20, 2016
@Dominik-K
Copy link

Dominik-K commented Oct 4, 2017

@progrium Unfortunately, the two env variants made it into the 0.4.0 release. Took me some time to figure this out.
With the upcoming 0.4.1 release, the SIGIL_DELIMS will be used.

@josegonzalez josegonzalez mentioned this pull request Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants