Giter VIP home page Giter VIP logo

plugin-haml's Introduction

Prettier for HAML

Gitter GitHub Actions NPM Version code style: prettier Follow+Prettier+on+Twitter

@prettier/plugin-haml is a prettier plugin for the HAML template language. prettier is an opinionated code formatter that supports multiple languages and integrates with most editors. The idea is to eliminate discussions of style in code review and allow developers to get back to thinking about code design instead.

Getting started

To run prettier with the HAML plugin, you're going to need ruby and node (version 8.3 or newer).

If you're using the npm CLI, then add the plugin by:

npm install --save-dev prettier @prettier/plugin-haml

Or if you're using yarn, then add the plugin by:

yarn add --dev prettier @prettier/plugin-haml

The prettier executable is now installed and ready for use:

./node_modules/.bin/prettier --write '**/*.haml'

Configuration

Below are the options that @prettier/plugin-haml currently supports:

API Option CLI Option Default Description
printWidth --print-width 80 Same as in Prettier (see prettier docs).
requirePragma --require-pragma false Same as in Prettier (see prettier docs).
tabWidth --tab-width 2 Same as in Prettier (see prettier docs)

Any of these can be added to your existing prettier configuration file. For example:

{
  "printWidth": 120
}

Or, they can be passed to prettier as arguments:

prettier --print-width 120 --write '**/*.haml'

Contributing

Check out our contributing guide. Bug reports and pull requests are welcome on GitHub at https://github.com/prettier/plugin-haml.

License

The package is available as open source under the terms of the MIT License.

plugin-haml's People

Contributors

kddnewton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin-haml's Issues

Installation error: "cannot load such file -- haml (LoadError)"

Hey!

First off, thank you so much for this plugin, as it makes developing in HAML a breeze.

I opened this issue because I encountered several problems during installation, some of them I don’t really know where they come from. I managed to hack my way through to a solution, which I will post here also in case it helps someone else out there.

Implicit haml requirement

This line

require 'haml'

is an implicit requirement on the haml gem. That raised the following error at runtime in VSCode:

`require': cannot load such file -- haml (LoadError)

As this plugin is supposed to, well, work with haml, one could think that the requirement will always be fulfilled. However that was not the case for me. That brings me to my second issue.

VSCode is not using my rbenv version of ruby

The VSCode stacktrace was mentioning the following path for Ruby when using this plugin /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby, which is the OSX default one and not the one used by my shell, development environment or otherwise as all of those are managed by rbenv.

I don’t know why that is, but that’s the reason why haml wasn’t installed (as I never use the system version of ruby).

The (admittedly dirty) fix to my issue was then to run the following command:

sudo /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem install haml

I think finding a way to have the plugin use the “correct” path to ruby for rbenv users would solve all this.

Feel free to close this issue if it is out of scope of the plugin (I don’t have a clue what’s going on. Otherwise, I’d be happy to help in any way I can!

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.