Skip to content

This is a simple golang helper to extract values from a string based on a template pattern.

License

Notifications You must be signed in to change notification settings

natekfl/untemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Untemplate

This is a simple golang helper to extract values from a string based on a template pattern. Similar to extract-values

Examples

untemplater1, _ := untemplate.Create("/{year}/{month}/{day}/{title}.html")
result1, _ := untemplater1.Extract("/2012/08/12/test.html")
//result1 > map[string]string{"day":"12", "month":"08", "title":"test", "year":"2012"}

untemplater2, _ := untemplate.Create("{name} <{email}> ({url})")
result2, _ := untemplater2.Extract("John Doe <[email protected]> (http://example.com)")
//result2 > map[string]string{"email":"[email protected]", "name":"John Doe", "url":"http://example.com"}

untemplater3, _ := untemplate.Create("Convert {quantity} {from_unit} to {to_unit}")
result3, _ := untemplater3.Extract("Convert 1500 Grams to Kilograms")
//result3 > map[string]string{"from_unit":"Grams", "quantity":"1500", "to_unit":"Kilograms"}

Installation

Install using go cli

go get github.com/natekfl/untemplate

About

This is a simple golang helper to extract values from a string based on a template pattern.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages