Go implementation for Soy templates (Google Closure templates)

soy

GoDoc Build Status Go Report Card

Go implementation for Soy templates aka Google Closure Templates. See godoc for more details and usage examples.

This project requires Go 1.12 or higher due to one of the transitive dependencies requires it as a minimum version; otherwise, Go 1.11 would suffice for go mod support.

Be sure to set the env var GO111MODULE=on to use the go mod dependency versioning when building and testing this project.

Owner
Comments
  • soyhtml/scope Modifies Template Input Data

    soyhtml/scope Modifies Template Input Data

    Similar to #6, but soyhtml/scope::enter() seems to modify the input map by setting a value for the "__all" key. Obviously not a huge deal, but thought I would bring it up.

  • PC-24819: make soyjs output ES6 compatible javascript (imports/exports)

    PC-24819: make soyjs output ES6 compatible javascript (imports/exports)

    • export functions that are declared (templates)
    • import functions that are not already in the file and are called (call, print directive, func)
    • maintains ES5 compatibility
    • callers can define and pass their own JSFormatter or use the ones provided by soyjs
  • i18n vs master?

    i18n vs master?

    Of the recent merged PRs, some are merged into master and others into i18n. Is there a preferred target? Is there a reason i18n needs to remain out of master or can we consider merging them and using master moving forward? cc @theothertomelliott @angelaxu1

  • Reimplement ObligatoryPrintDirectives from #52,#53 with less performa…

    Reimplement ObligatoryPrintDirectives from #52,#53 with less performa…

    …nce impact

    Results from running the tests from @meirf.

    Before my initial change:

    Requests: 60, Rate: 3, Success: 1.00
    Overall: 165.448656, 136.608661, 214.184631
    Success: 165.448656, 136.608661, 214.184631
    Failure: -9223372036854.777344, 0.000000, 0.000000
    Errors: map[]
    Duration: 19.666666565s, Wait: 134.146821ms
    

    After my first change which caused problems:

    Requests: 60, Rate: 3, Success: 0.57
    Overall: 17300.647065, 20130.723387, 30005.494537
    Success: 7586.369193, 2750.153252, 26260.900133
    Failure: 30003.933512, 30003.723974, 30006.367406
    Errors: map[Get net/http: timeout awaiting response headers:26]
    Duration: 19.66835212s, Wait: 30.006367406s
    

    This updated version:

    Requests: 60, Rate: 3, Success: 1.00
    Overall: 136.550875, 132.565442, 162.489595
    Success: 136.550875, 132.565442, 162.489595
    Failure: -9223372036854.777344, 0.000000, 0.000000
    Errors: map[]
    Duration: 19.666666585s, Wait: 123.45296ms
    
  • Add deprecated-contextual as a valid autoescape value.

    Add deprecated-contextual as a valid autoescape value.

    contextual has been renamed to deprecated-contextual in the official implementation [1]. This change allows soy to support both the old syntax and the new one in the meanwhile.

    [1] https://github.com/google/closure-templates/blob/2845e9a3836e7bf8d7166df2b7c79a5fa59fad60/java/src/com/google/template/soy/soytree/AutoescapeMode.java#L39

  • Return a pointer from NewMessage to store it easier.

    Return a pointer from NewMessage to store it easier.

    This changes allows to store the generated messages in something like map[uint64]*soymsg.Message without the hassle of a temporary variable. For example we can now do this:

    cache := map[uint64]*soymsg.Message{}
    cache[message.ID] = soymsg.NewMessage(message.ID, message.Value)
    

    instead of this:

    cache := map[uint64]*soymsg.Message{}
    m := soymsg.NewMessage(message.ID, message.Value)
    cache[message.ID] = &m
    
  • Add dep versioning and update tested Go versions

    Add dep versioning and update tested Go versions

    • add go.mod and go.sum files to manage dependencies with pinned versions for consistency and reproducibility
    • add env var GO111MODULE=on to .travis.yml to ensure use of go mod for dependency versioning and management, which was introduced in Go 1.11 and was optional then, and automatic in later versions
    • this functionality requires Go 1.11 or later, but as noted in issue #72, Go 1.12 and older are already technically EOL due to the release of 2 more major versions since then (1.13 and 1.14)
    • update .travis.yml to remove all versions prior to Go 1.11; also added newer versions of Go: 1.12, 1.13, 1.14

    Fixes #72

  • Add ObligatoryPrintDirectives

    Add ObligatoryPrintDirectives

    We sometimes print things that unexpectedly turn out to be null. This change would allow us to apply a default print directive that makes null render as an empty string instead of the text "null".

  • Fixed String() bugs for binary operators

    Fixed String() bugs for binary operators

    EqNode should print the equals comparator and "and"/"or" need spaces before and after them when printed so that words don't run together.

  • Google Closure Version Compatibility?

    Google Closure Version Compatibility?

    Hey!

    I noticed that some syntax that the Google Closure examples had weren't compiling with this library. What features does this library lack? Is it meant to conform only with one version of Closure?

  • Calling soy template recursively causes stackoverflow

    Calling soy template recursively causes stackoverflow

    This was a stupid error on my part, but it took a few minutes to figure out what I had done wrong. Would be nice to track which methods have been called and report a 'recursive template invocation' message to the user. Example is simplified.

    /**
     * @param title
     */
    {template .body}
    
    {call .body}
    {param title: 'Foo' /}
    {/call}
    
    {/template}
    
    goroutine 16 [stack growth]:
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eba40, 0x22083707f8, 0x2083ee9c0)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:63 fp=0x26845e668 sp=0x26845e660
    github.com/robfig/soy/soyhtml.(*state).evalPrint(0x20b8eba40, 0x2083ee9f0)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:290 +0x6c fp=0x26845e868 sp=0x26845e668
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eba40, 0x2208370918, 0x2083ee9f0)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:83 +0x52d5 fp=0x26845efd8 sp=0x26845e868
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eba40, 0x2208370948, 0x2083fda80)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:78 +0x1f00 fp=0x26845f748 sp=0x26845efd8
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eba40, 0x2208370888, 0x2083eee40)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:75 +0x1b4 fp=0x26845feb8 sp=0x26845f748
    github.com/robfig/soy/soyhtml.(*state).evalCall(0x20b8eb980, 0x208379450)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:382 +0x703 fp=0x268460150 sp=0x26845feb8
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eb980, 0x2208370858, 0x208379450)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:146 +0xd72 fp=0x2684608c0 sp=0x268460150
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eb980, 0x2208370948, 0x2083fda80)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:78 +0x1f00 fp=0x268461030 sp=0x2684608c0
    github.com/robfig/soy/soyhtml.(*state).walk(0x20b8eb980, 0x2208370888, 0x2083eee40)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:75 +0x1b4 fp=0x2684617a0 sp=0x268461030
    github.com/robfig/soy/soyhtml.(*state).evalCall(0x20b8eb8c0, 0x208379450)
        /Users/pcj/gocode/src/github.com/robfig/soy/soyhtml/exec.go:382 +0x703 fp=0x268461a38 sp=0x2684617a0
    
  • Replace Travis CI with GitHub Actions?

    Replace Travis CI with GitHub Actions?

    Looking at https://travis-ci.org/github/robfig/soy, the last time it ran was over 2 years ago, so this project is currently without automatic testing for new PRs.

    Additionally, there's a message at the top of the page:

    Since June 15th, 2021, the building on travis-ci.org is ceased. Please use travis-ci.com from now on.

    Would you be open to converting the Travis CI config for this project to GitHub Actions?

    Should be pretty straight-forward, happy to help with this. In fact, looking at the history, looks like I made the last change to the .travis.yml config file, over 2 years ago now (!) anyway. :-)

  • Use CodeLingo to Address Further Issues

    Use CodeLingo to Address Further Issues

    Hi @robfig! Thanks for merging the fixes from our earlier pull request. They were generated by CodeLingo which we've used to find a further 6 issues in the repo. This PR adds a set of CodeLingo Tenets which catch any new cases of the found issue in PRs to your repo.

    We're most interested to see if we can help with project specific bugs. Tell us about more interesting issues and we'll see if our tech can help - free of charge. Thanks, Angus and the CodeLingo Team

  • Support @param syntax in templates

    Support @param syntax in templates

    The documentation for Closure Templates has examples of the param syntax:

    {template .helloName}
      {@param name: string}
      Hello {$name}!
    {/template}
    

    This parser does not seem to support that though - I get:

    lexical error: unrecognized character in action: U+0040 '@'

    I think an older syntax for the same was to use comments:

    /** 
     * @param name
     */
    

    But that is no longer supported by some other parsers we use, and this one which does not support the new one. I think I would be great to add support for this.

    I might be able to contribute something - is somebody already aware of this issue or has tried to fix it? Any pointers?

  • autoescape=

    autoescape="strict" not supported

    When trying to use a template which explicitly specifies autoescape="strict" this package fails with:

    expected "true", "false", or "contextual" for autoescape, got "strict"

    As several of the closure-templates example files specify strict autoescape they are not usable without modification. Strict autoescaping was added to soy templates in the April 2014 release and is now the new default. Do any plans exist to add support to this package?

  • Convert

    Convert "ID", "URL", ... to lowercase in templates

    This is more an open question to discuss it. Should the library convert to lowercase common initialisms when they are at the start of a field name? Right now it uses only the first letter and it returns "iD" and "uRL".

    We could also use the struct field tag to allow custom names when converting to data.Map.

Related tags
Programatic document generation as a HTTP service. Render PDFs using LaTeX templates and JSON.
Programatic document generation as a HTTP service. Render PDFs using LaTeX templates and JSON.

LaTTe Generate PDFs using LaTeX templates and JSON. Try out the demo! Find LaTTe on Docker Hub Table of Contents About Obtaining LaTTe Running & Using

Dec 29, 2022
Go templates invoked as functions

Package tmplfunc provides an extension of Go templates in which templates can be invoked as if they were functions. See the package documentation for

Dec 22, 2022
"to be defined" - a really simple way to create text templates with placeholders

tbd "to be defined" A really simple way to create text templates with placeholders. This tool is deliberately simple and trivial, no advanced features

Sep 27, 2022
Universal JSON, BSON, YAML, CSV, XML converter with templates
Universal JSON, BSON, YAML, CSV, XML converter with templates

Universal JSON, BSON, YAML, CSV, XML translator to ANY format using templates Key features Various input formats (json, bson, yaml, csv, xml) Flexible

Dec 11, 2022
Allows you to fill in variables in your custom project templates.

go-templater The best project templater go-templater lets you use any project template you want and replace the variables with values from the config.

Nov 6, 2021
Callable Ajax / http requests inside Golang templates

jaco Callable Ajax / http requests inside Golang templates Examples Examples #1 {{ define "content" }} <div id="myTodos"></div> <script>

Dec 5, 2021
Templating system for HTML and other text documents - go implementation

FAQ What is Kasia.go? Kasia.go is a Go implementation of the Kasia templating system. Kasia is primarily designed for HTML, but you can use it for any

Mar 15, 2022
An example of implementation of Clean Architecture in Golang

Golang Template Description This is an example of implementation of Clean Archit

Dec 29, 2021
Community edition nuclei templates, a simple tool that allows you to organize all the Nuclei templates offered by the community in one place

cent Community edition nuclei templates, a simple tool that allows you to organize all the Nuclei templates offered by the community in one place Inst

Jan 9, 2023
Data Connector is a Google Sheets Add-on that lets you import (and export) data to/from Google Sheets

Data Connector Data Connector is a Google Sheets Add-on that lets you import (and export) data to/from Google Sheets. Our roadmap: Connect to JSON/XML

Jul 30, 2022
Jacket of google/wire: advanced DI approach wrapping google/wire for cloud.
Jacket of google/wire: advanced DI approach wrapping google/wire for cloud.

Wire-Jacket: IoC Container of google/wire for cloud-native Jacket of google/wire: advanced DI approach wrapping google/wire for cloud. google/wire : h

Nov 21, 2022
Telegram + Google Sheet daily routine trackerTelegram + Google Sheet daily routine tracker

Telegram + Google Sheet daily routine tracker Deploy as serverless function Fork this repository and set secrets github secrets: API_DOMAIN - your ver

Oct 13, 2021
GC2 is a Command and Control application that allows an attacker to execute commands on the target machine using Google Sheet and exfiltrate data using Google Drive.
GC2 is a Command and Control application that allows an attacker to execute commands on the target machine using Google Sheet and exfiltrate data using Google Drive.

GC2 GC2 (Google Command and Control) is a Command and Control application that allows an attacker to execute commands on the target machine using Goog

Dec 13, 2022
Go-based search engine URL collector , support Google, Bing, can be based on Google syntax batch collection URL
Go-based search engine URL collector , support Google, Bing, can be based on Google syntax batch collection URL

Go-based search engine URL collector , support Google, Bing, can be based on Google syntax batch collection URL

Nov 9, 2022
Correct the timestamp of photo/video of Google Photo from Google takeout

Correct Timestamp of Google Photo from Google Takeout Development Environment: Ubuntu 20.04 Go 1.17 Usage Require Go 1.16 or later to build. go build

Sep 9, 2022
"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Yandex Files

Website | Documentation | Download | Contributing | Changelog | Installation | Forum Rclone Rclone ("rsync for cloud storage") is a command-line progr

Jan 9, 2023
Google-pay-decryptor - Google Pay payload decryptor Tool

Google Pay Decryptor Tool Tired of looking for information about cryptography an

Mar 20, 2022
Go language implementation of a blockchain based on the BDLS BFT protocol. The implementation was adapted from Ethereum and Sperax implementation

BDLS protocol based PoS Blockchain Most functionalities of this client is similar to the Ethereum golang implementation. If you do not find your quest

Oct 14, 2022
A Left-Leaning Red-Black (LLRB) implementation of balanced binary search trees for Google Go

GoLLRB GoLLRB is a Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary search trees in Go Language. Overview As of this writing and to

Dec 23, 2022
Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System".

Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System". Ships gRPC, REST APIs, newSQL, and an easy and granular permission language. Supports ACL, RBAC, and other access models.

Jan 8, 2023