prettier-plugin-go-template
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.11 • Public • Published

    prettier-plugin-go-template

    NPM Badge CodeCov Badge Contributions Badge

    Fixes formatting for go template files. The only peer dependency is prettier.

    npm install --save-dev prettier prettier-plugin-go-template

    The following file types are detected automatically: .gohtml, .gotmpl, .go.tmpl, .tmpl, .tpl, .html.tmpl

    GoHugo / .html

    To use it with GoHugo and basic .html files, you'll have to override the used parser inside your .prettierrc file:

    {
      overrides: [
        {
          files: ["*.html"],
          options: {
            parser: "go-template",
          },
        },
      ],
    }

    VSCode

    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.

    Additional Options

    // .prettierrc
    {
      /**
       * Enables & disables spacing between go statements.
       * E.g. {{ statement }} vs {{statement}}.
       * Default: true
       */
      "goTemplateBracketSpacing": true
    }

    Changelog

    v0.0.10

    • Resolve bug #19: Fix template comments.

    v0.0.9

    • Resolve bug of single line if statements.

    v0.0.8

    • Go block statements will now be indented accordingly. Except for else.
      • if, range, block, with, define, end

    v0.0.7

    • Fix broken shortcodes. Thanks to @alqu for discovering & fixing the bug.

    Contributors

    Thanks goes to these wonderful people (emoji key):


    alqu

    🐛 ⚠️ 💻

    Gabriel Monteagudo

    🐛

    Bryan

    🐛

    Andreas Richter

    🐛

    Noah Brenner

    💻 📖

    silverwind

    🤔

    Charles Pence

    🐛

    This project follows the all-contributors specification. Contributions of any kind welcome!

    Install

    npm i prettier-plugin-go-template

    DownloadsWeekly Downloads

    5,516

    Version

    0.0.11

    License

    MIT

    Unpacked Size

    68 kB

    Total Files

    9

    Last publish

    Collaborators

    • niklaspor