Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
prettier-plugin-go-template
Advanced tools
Prettier plugin for formatting Go & GoHugo templates.
Formatter plugin for go template files. The only peer dependency is prettier.
npm install --save-dev prettier prettier-plugin-go-template
Starting with Prettier 3 auto-discovery has been removed. Configuration is required ⬇️
// .prettierrc
{
"plugins": ["prettier-plugin-go-template"]
}
The following file types will be detected automatically:
.gohtml
, .gotmpl
, .go.tmpl
, .tmpl
, .tpl
, .html.tmpl
If you want to add support for .html
read the section on it below the examples.
Input | Output |
---|---|
|
|
.html
To use it with GoHugo and basic .html
files, you'll have to override the used parser inside your .prettierrc
file:
{
"plugins": ["prettier-plugin-go-template"]
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template",
},
},
],
}
Make sure to always have installed both dependencies:
prettier
prettier-plugin-go-template
Also make sure that they are installed inside the same scope.
Install both globally (npm i -g
) or locally – otherwise prettier may not pick up the plugin.
Note: The global setup additional requires setting your VSCode prettier path to your global prettier path. You can read in this issue how to set it up – should be doable in less than a minute if you have npm & VSCode already running.
// .prettierrc
{
/**
* Enables & disables spacing between go statements.
* E.g. {{ statement }} vs {{statement}}.
* Default: true
*/
"goTemplateBracketSpacing": true
}
<div>
<!-- prettier-ignore -->
{{if }}
{{end }}
</div>
<html>
{{/* prettier-ignore-start */}}
<script>
{{if }}
Whatever.
{{else }}
Psych.
{{end }}
</script>
{{/* prettier-ignore-end */}}
</html>
Thanks goes to these wonderful people (emoji key):
alqu 🐛 ⚠️ 💻 | Gabriel Monteagudo 🐛 | Bryan 🐛 | Andreas Richter 🐛 | Noah Brenner 💻 📖 | silverwind 🤔 | Charles Pence 🐛 |
Caleb Jasik 🐛 📖 💡 🤔 🚧 💬 | Dan Gold 🐛 | Michael Lynch 🐛 |
This project follows the all-contributors specification. Contributions of any kind welcome!
0.0.15
FAQs
Prettier plugin for formatting Go & GoHugo templates.
The npm package prettier-plugin-go-template receives a total of 10,977 weekly downloads. As such, prettier-plugin-go-template popularity was classified as popular.
We found that prettier-plugin-go-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.