Skip to content

Commit

Permalink
bug fix: multiple ${..} in one line
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhanseng committed Dec 9, 2017
1 parent 475e398 commit fb477fc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"presets": [
"es2015",
"es2016",
"es2017"
"es2017"
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
[stability-index]: https://nodejs.org/api/documentation.html#documentation_stability_index
[npm-image]: https://img.shields.io/npm/v/endent.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/endent
[travis-image]: https://img.shields.io/travis/ZhouHansen/endent.svg?style=flat-square
[travis-url]: https://travis-ci.org/ZhouHansen/endent
[travis-image]: https://img.shields.io/travis/indentjs/endent.svg?style=flat-square
[travis-url]: https://travis-ci.org/indentjs/endent
[dm-image]: http://img.shields.io/npm/dm/endent.svg?style=flat-square

An ES6 string tag that endows some indentation. Recommnend use it with [dedent](https://github.com/dmnd/dedent)! May help you generate pretty javascript template with dynamic json.
Expand Down
5 changes: 3 additions & 2 deletions __tests__/endent-tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import endent from '../'
import endent from '../endent.js'
import dedent from 'dedent'

describe('endent', () => {
Expand All @@ -14,13 +14,14 @@ describe('endent', () => {
}

var colors = ['red', 'pink', 'white']
var objectName = "someobj"

var jsFile = dedent(endent`
module.exports = store
function store (state, emitter) {
emitter.on("DOMContentLoaded", function () {
state["someobj"] = ${endent.pretty(someobj)}
state[${objectName}] = ${endent.pretty(someobj)}
state["colors"] = ${endent.pretty(colors)}
state["name"] = ${endent.pretty("jack")}
state["number"] = ${endent.pretty(123)}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js → dist/endent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function endent(strings) {

if (i < values.length) {
if (values[i] && values[i][ENDENT_ID]) {
var rawlines = raw[i].split('\n');
var rawlines = result.split('\n');
var l = rawlines[rawlines.length - 1].search(/\S/);
var endentation = ' '.repeat(l);
var valueLines = values[i][ENDENT_ID].split('\n');
Expand Down
2 changes: 1 addition & 1 deletion index.js → endent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function endent (strings, ...values) {

if (i < values.length) {
if (values[i] && values[i][ENDENT_ID]) {
var rawlines = raw[i].split('\n')
var rawlines = result.split('\n')
var l = rawlines[rawlines.length - 1].search(/\S/)
var endentation = ' '.repeat(l)
var valueLines = values[i][ENDENT_ID].split('\n')
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "endent",
"version": "1.0.0",
"version": "1.0.5",
"description": "➡️ ES6 string tag that endows indentation from multi-line strings",
"main": "dist/index.js",
"main": "dist/endent.js",
"files": [
"dist/index.js"
"dist/endent.js"
],
"scripts": {
"build": "babel index.js --out-file dist/index.js",
"build": "babel endent.js --out-file dist/endent.js",
"test": "jest"
},
"repository": {
Expand All @@ -27,7 +27,6 @@
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.22.2",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-es2017": "^6.22.0",
Expand Down

0 comments on commit fb477fc

Please sign in to comment.