Git Product home page Git Product logo

Comments (6)

LandGod avatar LandGod commented on July 17, 2024 8

+1 for the {{ else }} problems. My company is looking at running prettier as a pre-commit hook on our Hugo site, but having that hook indent every single {{ else }} block in the whole repo to the wrong level would be very sad. Would love to know if a fix is in the works for this.

from prettier-plugin-go-template.

NiklasPor avatar NiklasPor commented on July 17, 2024 1

@LandGod this will be fixed with #49 🙉

Example:

{{ partial "counts" . }}
{{ if .Params.module }}
  {{ $confidence := print "modules/" .Params.module "@" .Params.moduleVersion "/partials/confidence.html" }}
  {{ $feedbacks := print "modules/" .Params.module "@" .Params.moduleVersion "/partials/feedbacks.html" }}
  {{ $explanation := print "modules/" .Params.module "@" .Params.moduleVersion "/partials/explanation.html" }}
  {{ partial $confidence . }} {{ partial $feedbacks . }} {{ partial $explanation . }}
{{ else }}
  {{ partial "confidence" . }} {{ partial "feedbacks" . }} {{ partial "explanation" . }}
{{ end }}

This was with printWidth: 100 inside the .prettierrc.

from prettier-plugin-go-template.

NiklasPor avatar NiklasPor commented on July 17, 2024 1

@LandGod the wrapping behavior comes from the chained tags. (<div></div><span></span>).
If you instead add a space between the different elements, prettier will use new lines for separation.

This is a behavior of the underlying HTML printer, not from this plugin 👀

from prettier-plugin-go-template.

NiklasPor avatar NiklasPor commented on July 17, 2024

About the second wrapping, it's a prettier formatting thing.
If you put a space between the tags it'll break as you expect it to.

from prettier-plugin-go-template.

richtera avatar richtera commented on July 17, 2024

Ah perfect that makes sense. It's trying to not insert spaces where there were none :) cool.

from prettier-plugin-go-template.

richtera avatar richtera commented on July 17, 2024

The {{ else }} indentation problem seems to have come back in the latest version.
Strange, it was fine for a while now.

from prettier-plugin-go-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.