Skip to content

Add functions #32

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

Merged
merged 7 commits into from
Oct 31, 2014
Merged

Add functions #32

merged 7 commits into from
Oct 31, 2014

Conversation

md5
Copy link
Contributor

@md5 md5 commented Oct 29, 2014

This patch adds the following functions:

  • dict: creates a map from a list of pairs. facilitates passing data to subtemplates.
  • sha1: creates a sha1 hex string from another string
  • json: returns the JSON string representation of an object (cf. docker inspect)
  • last: returns the last element of an array or slice or the last character in a string

@thaJeztah
Copy link
Contributor

Thanks! Should there be some documentation added and possibly an example on how to make use of these?

@md5
Copy link
Contributor Author

md5 commented Oct 29, 2014

What fun would that be?

I didn't see a place in the docs that documents the current template functions, other than the de facto documentation in the examples. I suppose I could create an example or two. And now that I think about it, first would be nice...

@thaJeztah
Copy link
Contributor

😄 yes documentation is quite lacking. If you're able to dabble down some stuff, would be great!

@md5
Copy link
Contributor Author

md5 commented Oct 30, 2014

I've added a "Templating" section to the README.md.

In the process of writing it, I came across Hugo and it made me want to add most of their functions as well: http://gohugo.io/templates/functions/

However, I'd like to see this merged as is; I can open another PR to add more functions if (when) I get around to needing them.

@thaJeztah
Copy link
Contributor

Nice! And fully agreed, docs should not uphold merging of this PR (just my opinion)

Thanks a lot!

@jwilder
Copy link
Collaborator

jwilder commented Oct 30, 2014

This is failing to compile for me:

./template.go:15: imported and not used: "sort"

@md5
Copy link
Contributor Author

md5 commented Oct 30, 2014

Crap! I had run "go test" on this branch before pushing it, but then I decided to remove a half-ass implementation of "sort". I guess that dropping that commit wasn't enough...

jwilder added a commit that referenced this pull request Oct 31, 2014
@jwilder jwilder merged commit c885194 into nginx-proxy:master Oct 31, 2014
@jwilder
Copy link
Collaborator

jwilder commented Oct 31, 2014

Thanks!

@thaJeztah
Copy link
Contributor

👍

@md5
Copy link
Contributor Author

md5 commented Oct 31, 2014

Sweet!

My local branch has getenv and a couple other things that I'll be sending a PR for next week probably. I'm also still waiting for support for the TLS event stream to be merged in go-dockerclient, after which I can have a TLS PR for docker-gen.

At that point, it will be possible for everyone to use docker-gen on OS X like I've been doing :) (or with any TLS-enabled remote docker host for that matter)

@md5 md5 deleted the add-functions branch October 31, 2014 23:23
@thaJeztah
Copy link
Contributor

Sweet!

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