gruntwork-io / boilerplate

A tool for generating files and folders ("boilerplate") from a set of templates
https://www.gruntwork.io
Mozilla Public License 2.0
160 stars 12 forks source link

Helpers #2

Closed brikis98 closed 7 years ago

brikis98 commented 7 years ago

This PR adds a bunch of handy string and math helpers to boilerplate, such as dasherize, snakeCase, and round. This allows us to use a single value entered by a user in many different ways. For example, if a boilerplate.yml file defines a variable called companyName, and the user enters the name “Acme Co”, with these helpers, it’s now easy to generate a variety of different types of valid code with that text, such as:

BTW, this took quite a bit longer than expected because Go does not have many of these basic string and math manipulation functions built in. It doesn't even have a method to round numbers!! I found some open source implementations, but most were broken and incomplete, so I implemented my own with a thorough suite of tests.

brikis98 commented 7 years ago

@josh-padnick This is ready for review.

josh-padnick commented 7 years ago

It doesn't even have a method to round numbers!! I found some open source implementations, but most were broken and incomplete, so I implemented my own with a thorough suite of tests.

That is crazy. I had to google it myself to satisfy my incredulity!

josh-padnick commented 7 years ago

This code looks excellent. Nicely done as usual!