🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/veigaribo/template

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/veigaribo/template

v0.3.0
Source
Go
Version published
Created
Source

Redistribution of the standard text/template Go package with the following modifications:

Added the ~ and # space trimmers:

~ will only trim whitespace characters that do not represent a new line (CR or LF).

line 1
  {{~ "line 2"}}
line 3

=>
line 1
line 2
line 3

# will do:

  • If the trimmer is on the left, it will seek whitespace until it finds something that is not whitespace. Then, if it was on a different line from where it started, it will leave that line's line break behind and consume the rest. If there was trailing whitespace in that line, it will be kept too.

  • If the trimmer is on the right, it will seek whitespace until it finds something that is not whitespace. Then, if it was on a different line from where it started, it will leave that line's whitespace behind and consume the rest.

  line 1

  {{# "line 2"}}
  line 3

=>
  line 1
line 2
  line 3
  line 1
  {{"line 2" #}}

  line 3

=>
  line 1
  line 2  line 3

Made {{template}} allow terms as template names

{{- define "one" -}} I {{.}} {{- end -}}
{{- $tmpl := "one" -}}

{{template $tmpl "u"}}

=>
I u

Added shorthands for define and template

  • define -> def
  • template -> t
{{- def "one" -}} I {{.}} {{- end -}}
{{- $tmpl := "one" -}}

{{t $tmpl "u"}}

FAQs

Package last updated on 30 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts