-
Notifications
You must be signed in to change notification settings - Fork 0
Stemp - the simple templating program.
License
rythoris/stemp
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Stemp is a simple templating program. Stemp uses the golang's text/template and html/template under the hood and designed with the UNIX philosophy in mind, which means it is designed to be scriptable and you can easily pipe stuff to or from it to other programs. Examples ======== NOTE: In order to keep the examples simple, the shell is used in this examples is bash(1) because it supports "Process Substitution" (i.e. the <(...) stuff). By default stemp uses the file extention to determine the file type, but in cases where you don't have a file extention or in this case where we are passing the vars using process substitution we have to implicitly specify the format that were using. This is done using the '-f' or '--vars-format' option. $ echo "{{ .my_var }}" | stemp -f json - <(echo '{"my_var": "something"}') something $ echo "{{ .x | inc }}" | stemp -f json - <(echo 'x = 68') 69 By default stemp writes the result to stdout, you can write the output to a file by using the '-o' or '--output' options. $ echo "{{ range .xs }}{{ . }}{{ end }}" | stemp -f yaml -o out.txt - <(echo 'xs: ["a", "b", "c"]') $ cat out.txt abc You can use the 'safeHtml' function to escape html tags in order to prevent code injection. $ echo "{{ .unsafe_html | safeHtml }}" | stemp -f json - <(echo '{"unsafe_html": "<script>alert(1)</script>"}') -f json <script>alert(1)</script> Stemp Functions =============== List of stemp function mappings and their respective types: inc :: (int) -> int dec :: (int) -> int add :: (int, int) -> int sub :: (int, int) -> int div :: (int, int) -> int mul :: (int, int) -> int mod :: (int, int) -> int sin math.Sin cos math.Cos tan math.Tan abs math.Abs floor math.Floor ceil math.Ceil join strings.Join, trim strings.TrimSpace, trimPrefix strings.TrimPrefix, trimSuffix strings.TrimSuffix, hasPrefix strings.HasPrefix, hasSuffix strings.HasSuffix, upper strings.ToUpper, lower strings.ToLower, title strings.ToTitle, safeHtml template.HTMLEscapeString, Feel send a PR to extend this list. License ======= This project is licensed under the GPLv3 copyleft license.
About
Stemp - the simple templating program.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published