All Projects → MartinKolarik → babel-plugin-dedent

MartinKolarik / babel-plugin-dedent

Licence: MIT License
Remove indentation from multiline template strings

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to babel-plugin-dedent

medly-components
🧩 Medly components provides numerous themable react components, each with multiple varitaions of sizes, colors, position etc.
Stars: ✭ 66 (+106.25%)
Mutual labels:  babel
babel-plugin-private-underscores
Make _classMembers 'private' using symbols
Stars: ✭ 39 (+21.88%)
Mutual labels:  babel
gobang
一个五子棋AI,使用原生JavaScript开发
Stars: ✭ 22 (-31.25%)
Mutual labels:  babel
react-quiz-app
A Simple React Quiz App 💎
Stars: ✭ 37 (+15.63%)
Mutual labels:  babel
netflix landing-page
The Netflix.com landing page built via React 16 and Styled-Components. Build deployed via Surge.sh for preview.
Stars: ✭ 39 (+21.88%)
Mutual labels:  babel
cerebro-web
Website for Cerebro
Stars: ✭ 21 (-34.37%)
Mutual labels:  babel
babel-note
Some examples of babel
Stars: ✭ 12 (-62.5%)
Mutual labels:  babel
objective-c-parser
Get the JSON representation of an Objective-C header file
Stars: ✭ 19 (-40.62%)
Mutual labels:  babel
webpack-gulp-wordpress-starter-theme
A WordPress theme with Webpack & Gulp
Stars: ✭ 110 (+243.75%)
Mutual labels:  babel
2life-server
💌 双生:遇见另一半的美好:)(服务端)
Stars: ✭ 66 (+106.25%)
Mutual labels:  babel
k6-template-es6
Template repository for bundling test projects into single test scripts runnable by k6
Stars: ✭ 39 (+21.88%)
Mutual labels:  babel
find-unused-exports
A Node.js CLI and equivalent JS API to find unused ECMAScript module exports in a project.
Stars: ✭ 30 (-6.25%)
Mutual labels:  babel
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (+6.25%)
Mutual labels:  babel
freeRouter
freeRouter - networking swiss army knife
Stars: ✭ 26 (-18.75%)
Mutual labels:  babel
gulp-webpack-boilerplate
A good foundation for your next frontend project.
Stars: ✭ 56 (+75%)
Mutual labels:  babel
frontplate-cli
フロントエンドビルドCLI
Stars: ✭ 25 (-21.87%)
Mutual labels:  babel
vue-cms
VUE-CMS. Proudly Using ES7, Vue 2, Koa 2, Webpack 4, Babel 7 And Mocha
Stars: ✭ 16 (-50%)
Mutual labels:  babel
sample-ui-react
Material-UI+ React.js + Redux [ Pug / Scss / Babel ]
Stars: ✭ 15 (-53.12%)
Mutual labels:  babel
Webpack-Starter-Kit
Webpack 4 stater kit with SCSS, PostCSS, Babel & ESLint
Stars: ✭ 41 (+28.13%)
Mutual labels:  babel
babel-preset-react-native-web3
deprecated: babel preset for react native, web3 and babel 6
Stars: ✭ 22 (-31.25%)
Mutual labels:  babel

babel-plugin-dedent

Removes indentation from multiline template strings. Works with both tabs and spaces.

Not using Babel? Here's a runtime version of this plugin.

Installation

$ npm install babel babel-plugin-dedent
$ babel --plugins dedent script.js

Babel v6+

v2.x.x of this plugin is required. Older versions are not compatible with Babel v6+.

Usage

Indentation will be removed from all strings tagged with dedent tag (you can also use dedent as a function, if you need to use your own tag).

expect(dedent`Line #1
	Line #2
	Line #3`).to.equal('Line #1\nLine #2\nLine #3');

// Leading/trailing line break is removed.
expect(
	dedent`
	Line #1
	Line #2
	Line #3
	`
).to.equal('Line #1\nLine #2\nLine #3');

// No more than one leading/trailing line break is removed.
expect(
	dedent`

	Line #1
	Line #2
	Line #3

	`
).to.equal('\nLine #1\nLine #2\nLine #3\n');

// Only the "base" indentation is removed.
expect(
	dedent`
	Line #1
		Line #2
			Line #3
	`
).to.equal('Line #1\n\tLine #2\n\t\tLine #3');

// The last line is ignored if it doesn't contain anything else than whitespace.
expect(
	function () {
		return dedent`
			Line #1
			Line #2
			Line #3
		`;
	}()
).to.equal('Line #1\nLine #2\nLine #3');

// Escaped characters are ignored.
expect(
	dedent`
	\tLine #1
	\tLine #2
	\tLine #3
	`
).to.equal('\tLine #1\n\tLine #2\n\tLine #3');

License

Copyright (c) 2015 - 2020 Martin Kolárik. Released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].