Giter VIP home page Giter VIP logo

common-tags's Introduction

common-tags

πŸ”– A set of well-tested, commonly used template literal tag functions for use in ES2015+.

🌟 Plus some extra goodies for easily making your own tags.

Example

import { html } from 'common-tags';

html`
  <div id="user-card">
    <h2>${user.name}</h2>
  </div>
`

Project Status

Info Badges
Version github release npm version
License npm license
Popularity npm downloads
Testing Build status build status codecov.io
Quality dependency status dev dependency status
Style code style: prettier

Table of Contents

Introduction

common-tags initially started out as two template tags I'd always find myself writing - one for stripping indents, and one for trimming multiline strings down to a single line. In its prime, I was an avid user of CoffeeScript, which had this behaviour by default as part of its block strings feature. I also started out programming in Ruby, which has a similar mechanism called Heredocs.

Over time, I found myself needing a few more template tags to cover edge cases - ones that supported including arrays, or ones that helped to render out tiny bits of HTML not large enough to deserve their own file or an entire template engine. So I packaged all of these up into this module.

As more features were proposed, and I found myself needing a way to override the default settings to cover even more edge cases, I realized that my initial implementation wouldn't be easy to scale.

So I re-wrote this module on top of a core architecture that makes use of transformer plugins which can be composed, imported independently and re-used.

Why You Should Care

Tagged templates in ES2015 are a welcome feature. But, they have their downsides. One such downside is that they preserve all whitespace by default - which makes multiline strings in source code look terrible.

Source code is not just for computers to interpret. Humans have to read it too 😁. If you care at all about how neat your source code is, or come from a CoffeeScript background and miss the block string syntax, then you will love common-tags, as it was initially intended to bring this feature "back" to JS since its initial commit.

common-tags also exposes a means of composing pipelines of dynamic transformer plugins. As someone with a little experience writing tagged templates, I can admit that it is often the case that one tag might need to do the same thing as another tag before doing any further processing; for example - a typical tag that renders out HTML could strip initial indents first, then worry about handling character escapes. Both steps could easily be useful as their own separate template tags, but there isn't an immediately obvious way of composing the two together for maximum re-use. common-tags offers not one, but two ways of doing this.

Furthermore, I try to keep this project as transparently stable and updated as frequently as I possibly can. As you may have already seen by the project status table, common-tags is linted, well tested, tests are well covered, tests pass on both Unix and Windows operating systems, the popularity bandwidth is easily referenced and dependency health is in plain sight πŸ˜„. common-tags is also already used in production on a number of proprietary sites and dependent projects, and contributions are always welcome, as are suggestions.

See Who Is Using common-tags

Installation

Requirements

The official recommendation for running common-tags is as follows:

It might work with below versions of Node, but this is not a guarantee.

Instructions

common-tags is a Node module. So, as long as you have Node.js and NPM installed, installing common-tags is as simple as running this in a terminal at the root of your project:

npm install common-tags

With unpkg

common-tags is also available at unpkg. Just put this code in your HTML:

<script src="https://unpkg.com/common-tags"></script>

This will make the library available under a global variable commonTags.

Usage

Imports

Like all modules, common-tags begins with an import. In fact, common-tags supports two styles of import:

Named imports:

import {stripIndent} from 'common-tags'

Direct module imports:

(Useful if your bundler doesn't support tree shaking but you still want to only include modules you need).

import stripIndent from 'common-tags/lib/stripIndent'

Available Tags

common-tags exports a bunch of wonderful pre-cooked template tags for your eager consumption. They are as follows:

html

Aliases: source, codeBlock

You'll often find that you might want to include an array in a template. Typically, doing something like ${array.join(', ')} would work - but what if you're printing a list of items in an HTML template and want to maintain the indentation? You'd have to count the spaces manually and include them in the .join() call - which is a bit ugly for my taste. This tag properly indents arrays, as well as newline characters in string substitutions, by converting them to an array split by newline and re-using the same array inclusion logic:

import {html} from 'common-tags'
let fruits = ['apple', 'orange', 'watermelon']
html`
  <div class="list">
    <ul>
      ${fruits.map(fruit => `<li>${fruit}</li>`)}
      ${'<li>kiwi</li>\n<li>guava</li>'}
    </ul>
  </div>
`

Outputs:

<div class="list">
  <ul>
    <li>apple</li>
    <li>orange</li>
    <li>watermelon</li>
    <li>kiwi</li>
    <li>guava</li>
  </ul>
</div>

safeHtml

A tag very similar to html but it does safe HTML escaping for strings coming from substitutions. When combined with regular html tag, you can do basic HTML templating that is safe from XSS (Cross-Site Scripting) attacks.

import {html, safeHtml} from 'common-tags'
let userMessages = ['hi', 'what are you up to?', '<script>alert("something evil")</script>']
html`
  <div class="chat-list">
    <ul>
      ${userMessages.map(message => safeHtml`<li>${message}</li>`)}
    </ul>
  </div>
`

Outputs:

<div class="chat-list">
  <ul>
    <li>hi</li>
    <li>what are you up to?</li>
    <li>&lt;script&gt;alert(&quot;something evil&quot;)&lt;/script&gt;</li>
  </ul>
</div>

oneLine

Allows you to keep your single-line strings under 80 characters without resorting to crazy string concatenation.

import {oneLine} from 'common-tags'

oneLine`
  foo
  bar
  baz
`
// "foo bar baz"

oneLineTrim

Allows you to keep your single-line strings under 80 characters while trimming the new lines:

import {oneLineTrim} from 'common-tags'

oneLineTrim`
  https://news.com/article
  ?utm_source=designernews.co
`
// https://news.com/article?utm_source=designernews.co

stripIndent

If you want to strip the initial indentation from the beginning of each line in a multiline string:

import {stripIndent} from 'common-tags'

stripIndent`
  This is a multi-line string.
  You'll ${verb} that it is indented.
  We don't want to output this indentation.
    But we do want to keep this line indented.
`
// This is a multi-line string.
// You'll notice that it is indented.
// We don't want to output this indentation.
//   But we do want to keep this line indented.

Important note: this tag will not indent multiline strings coming from the substitutions. If you want that behavior, use the html tag (aliases: source, codeBlock).

stripIndents

If you want to strip all of the indentation from the beginning of each line in a multiline string:

import {stripIndents} from 'common-tags'

stripIndents`
  This is a multi-line string.
  You'll ${verb} that it is indented.
  We don't want to output this indentation.
    We don't want to keep this line indented either.
`
// This is a multi-line string.
// You'll notice that it is indented.
// We don't want to output this indentation.
// We don't want to keep this line indented either.

inlineLists

Allows you to inline an array substitution as a list:

import {inlineLists} from 'common-tags'

inlineLists`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples bananas watermelons
// They're good!

oneLineInlineLists

Allows you to inline an array substitution as a list, rendered out on a single line:

import {oneLineInlineLists} from 'common-tags'

oneLineInlineLists`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples bananas watermelons They're good!

commaLists

Allows you to inline an array substitution as a comma-separated list:

import {commaLists} from 'common-tags'

commaLists`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas, watermelons
// They're good!

commaListsOr

Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or":

import {commaListsOr} from 'common-tags'

commaListsOr`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas or watermelons
// They're good!

commaListsAnd

Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and":

import {commaListsAnd} from 'common-tags'

commaListsAnd`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas and watermelons
// They're good!

oneLineCommaLists

Allows you to inline an array substitution as a comma-separated list, and is rendered out on to a single line:

import {oneLineCommaLists} from 'common-tags'

oneLineCommaLists`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas, watermelons They're good!

oneLineCommaListsOr

Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or", and is rendered out on to a single line:

import {oneLineCommaListsOr} from 'common-tags'

oneLineCommaListsOr`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas or watermelons They're good!

oneLineCommaListsAnd

Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and", and is rendered out on to a single line:

import {oneLineCommaListsAnd} from 'common-tags'

oneLineCommaListsAnd`
  I like ${['apples', 'bananas', 'watermelons']}
  They're good!
`
// I like apples, bananas and watermelons They're good!

id

A no-op tag that might come in useful in some scenarios, e.g. mocking.

import {id} from 'common-tags'

id`hello ${'world'}`
// hello world

Advanced Usage

Tail Processing

It's possible to pass the output of a tagged template to another template tag in pure ES2015+:

import {oneLine} from 'common-tags'

oneLine`
  ${String.raw`
    foo
    bar\nbaz
  `}
`
// "foo bar\nbaz"

We can make this neater. Every tag common-tags exports can delay execution if it receives a function as its first argument. This function is assumed to be a template tag, and is called via an intermediary tagging process before the result is passed back to our tag. Use it like so (this code is equivalent to the previous code block):

import {oneLine} from 'common-tags'

oneLine(String.raw)`
  foo
  bar\nbaz
`
// "foo bar\nbaz"

Using Tags on Regular String Literals

Sometimes you might want to use a tag on a normal string (e.g. for stripping the indentation). For that purpose just call a tag as a function with the passed string:

import {stripIndent} from 'common-tags'

stripIndent("  foo\n    bar")
// "foo\n  bar"

Type Definitions

There are third-party type definitions for common-tags on npm. Just install them like so:

npm install @types/common-tags

Please note that these type definitions are not officially maintained by the authors of common-tags - they are maintained by the TypeScript community.

Make Your Own Template Tag

common-tags exposes an interface that allows you to painlessly create your own template tags.

Where It All Starts: createTag

common-tags exports a createTag function. This function is the foundation of common-tags. The concept of the function works on the premise that transformations occur on a template either when the template is finished being processed (onEndResult), or when the tag encounters a string (onString) or a substitution (onSubstitution). Any tag produced by this function supports tail processing.

The easiest tag to create is a tag that does nothing:

import {createTag} from 'common-tags'

const doNothing = createTag()

doNothing`foo bar`
// 'foo bar'

The Anatomy of a Transformer

createTag receives either an array or argument list of transformers. A transformer is just a plain object with three optional methods - getInitialContext, onString, onSubstitution and onEndResult - it looks like this:

{
  getInitialContext () {
    // optional. Called before everything else.
    // The result of this hook will be passed to other hooks as `context`.
    // If omitted, `context` will be an empty object.
  },
  onString (str, context) {
    // optional. Called when the tag encounters a string.
    // (a string is whatever's not inside "${}" in your template literal)
    // `str` is the value of the current string
  },
  onSubstitution (substitution, resultSoFar, context) {
    // optional. Called when the tag encounters a substitution.
    // (a substitution is whatever's inside "${}" in your template literal)
    // `substitution` is the value of the current substitution
    // `resultSoFar` is the end result up to the point of this substitution
  },
  onEndResult (endResult, context) {
    // optional. Called when all substitutions have been parsed
    // `endResult` is the final value.
  }
}

Plugin Transformers

You can wrap a transformer in a function that receives arguments in order to create a dynamic plugin:

const substitutionReplacer = (oldValue, newValue) => ({
  onSubstitution(substitution, resultSoFar) {
    if (substitution === oldValue) {
      return newValue
    }
    return substitution
  }
})

const replaceFizzWithBuzz = createTag(substitutionReplacer('fizz', 'buzz'))

replaceFizzWithBuzz`foo bar ${"fizz"}`
// "foo bar buzz"

Plugin Pipeline

You can pass a list of transformers, and createTag will call them on your tag in the order they are specified:

// note: passing these as an array also works
const replace = createTag(
  substitutionReplacer('fizz', 'buzz'),
  substitutionReplacer('foo', 'bar')
)

replace`${"foo"} ${"fizz"}`
// "bar buzz"

When multiple transformers are passed to createTag, they will be iterated three times - first, all transformer onString methods will be called. Once they are done processing, onSubstitution methods will be called. Finally, all transformer onEndResult methods will be called.

Returning Other Values from a Transformer

All transformers get an additional context argument. You can use it to calculate the value you need:

const listSubs = {
  getInitialContext() {
    return { strings: [], subs: [] }
  },
  onString(str, context) {
    context.strings.push(str)
    return str
  },
  onSubstitution(sub, res, context) {
    context.subs.push({ sub, precededBy: res })
    return sub
  },
  onEndResult(res, context) {
    return context
  }
}

const toJSON = {
  onEndResult(res) {
    return JSON.stringify(res, null, 2)
  }
}

const log = {
  onEndResult(res) {
    console.log(res)
    return res
  }
}

const process = createTag([listSubs, toJSON, log])

process`
  foo ${'bar'}
  fizz ${'buzz'}
`
// {
//  "strings": [
//    "\n  foo ",
//    "\n  foo bar\n  fizz ",
//    "\n" 
//  ],
//  "subs": [
//    {
//      "sub": "bar",
//      "precededBy": "\n  foo "
//    },
//    {
//      "sub": "buzz",
//      "precededBy": "\n  foo bar\n  fizz "
//    }
//  ]
// }

List of Built-in Transformers

Since common-tags is built on the foundation of this createTag function, it comes with its own set of built-in transformers:

trimResultTransformer([side])

Trims the whitespace surrounding the end result. Accepts an optional side (can be "start" or "end" or alternatively "left" or "right") that when supplied, will only trim whitespace from that side of the string.

stripIndentTransformer([type='initial'])

Strips the indents from the end result. Offers two types: all, which removes all indentation from each line, and initial, which removes the shortest indent level from each line. Defaults to initial.

replaceResultTransformer(replaceWhat, replaceWith)

Replaces a value or pattern in the end result with a new value. replaceWhat can be a string or a regular expression, replaceWith is the new value.

replaceSubstitutionTransformer(replaceWhat, replaceWith)

Replaces the result of all substitutions (results of calling ${ ... }) with a new value. Same as for replaceResultTransformer, replaceWhat can be a string or regular expression and replaceWith is the new value.

replaceStringTransformer(replaceWhat, replaceWith)

Replaces the result of all strings (what's not in ${ ... }) with a new value. Same as for replaceResultTransformer, replaceWhat can be a string or regular expression and replaceWith is the new value.

inlineArrayTransformer(opts)

Converts any array substitutions into a string that represents a list. Accepts an options object:

opts = {
  separator: ',', // what to separate each item with (always followed by a space)
  conjunction: 'and', // replace the last separator with this value
  serial: true // should the separator be included before the conjunction? As in the case of serial/oxford commas
}
splitStringTransformer(splitBy)

Splits a string substitution into an array by the provided splitBy substring, only if the string contains the splitBy substring.

How to Contribute

Please see the Contribution Guidelines.

License

MIT. See license.md.

Other ES2015 Template Tag Modules

If common-tags doesn't quite fit your bill, and you just can't seem to find what you're looking for - perhaps these might be of use to you?

  • tage - make functions work as template tags too
  • is-tagged - Check whether a function call is initiated by a tagged template string or invoked in a regular way
  • es6-template-strings - Compile and resolve template strings notation as specified in ES6
  • t7 - A light-weight virtual-dom template library
  • html-template-tag - ES6 Tagged Template for compiling HTML template strings.
  • clean-tagged-string - A simple utility function to clean ES6 template strings.
  • multiline-tag - Tags for template strings making them behave like coffee multiline strings
  • deindent - ES6 template string helper for deindentation.
  • heredoc-tag - Heredoc helpers for ES2015 template strings
  • regx - Tagged template string regular expression compiler.
  • regexr - Provides an ES6 template tag function that makes it easy to compose regexes out of template strings without double-escaped hell.
  • url-escape-tag - A template tag for escaping url parameters based on ES2015 tagged templates.
  • shell-escape-tag - An ES6+ template tag which escapes parameters for interpolation into shell commands.
  • sql-tags - ES6 tagged template string functions for SQL statements.
  • sql-tag - A template tag for writing elegant sql strings.
  • sequelize-sql-tag - A sequelize plugin for sql-tag
  • pg-sql-tag - A pg plugin for sql-tag
  • sql-template-strings - ES6 tagged template strings for prepared statements with mysql and postgres
  • sql-composer - Composable SQL template strings for Node.js
  • pg-template-tag - ECMAScript 6 (2015) template tag function to write queries for node-postgres.
  • digraph-tag - ES6 string template tag for quickly generating directed graph data
  • es2015-i18n-tag - ES2015 template literal tag for i18n and l10n translation and localization

common-tags's People

Contributors

albkn avatar cdcorey avatar do7be avatar eduard-malakhov avatar fatfisz avatar feross avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hjdivad avatar ibrahima avatar jakeweary avatar jkillian avatar josephfrazier avatar k15a avatar kamilogorek avatar lucianbuzzo avatar shannonmoeller avatar skolmer avatar zspecza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

common-tags's Issues

Investigate chaining

Being able to chain an infinite amount of tags would be really useful.

It would basically be the same functionality as the tail processing syntax:

tag(otherTag)`some text`

but instead of being limited to one extra tag, you could chain as many as you want

tag.otherTag.thirdTag`some text`

An in-range update of doctoc is breaking the build 🚨

Version 1.2.0 of doctoc just got published.

Branch Build failing 🚨
Dependency doctoc
Current Version 1.1.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As doctoc is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ bitHound - Dependencies 1 failing dependency. Details

  • βœ… bitHound - Code No failing files. Details

Commits

The new version differs by 5 commits .

  • a376096 1.2.0
  • 9603fa2 doc: updating TOC in Readme with extra option
  • bb4f414 Added option for stdout
  • eab6f48 Peg anchor-markdown-header to ^0.5.5 (#110)
  • ec0157b Adds --entryprefix flag to use '*' instead of '-'

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Additional option: indent inserted content

Arrays are nicely indented:

html`
    <ul>
        ${['foo', 'bar'].map(x => `<li>${x}</li>`)}
    </ul>
    `

The output is:

<ul>
    <li>foo</li>
    <li>bar</li>
</ul>

Occasionally, one may insert chunks of text, not Arrays. Then it’d be great to have the option of indenting text after line breaks. In other words, the following code should produce the same output as the previous code:

html`
    <ul>
        ${'<li>foo</li>\n<li>bar</li>'}
    </ul>
    `

Don't assume array expression has preceding whitespace

When includeArrays is used & an array expression has a non-whitespace character preceding it, an error is thrown. Example:

import { commaLists } from 'common-tags';

let templ, myArray = [ 'a', 'b', 'c' ];

// Does not work
templ = commaLists`
    (${myArray})
`;

// Add a space before the expression & suddenly it works.
templ = commaLists`
    ( ${myArray})
`;

I believe it's reasonable to expect to be able to produce output like (a, b, c).

The error is Cannot read property '1' of null, stemming from this line in tags.js:

expression = expression.join(sep + accumulator.match(/(\s+)$/)[1])

If there's no whitespace at the end of accumulator to copy, perhaps it could default to using a single space.

An in-range update of babel-eslint is breaking the build 🚨

Version 7.1.1 of babel-eslint just got published.

Branch Build failing 🚨
Dependency babel-eslint
Current Version 7.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-eslint is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ bitHound - Dependencies 1 failing dependency. Details

  • βœ… bitHound - Code No failing files. Details

Commits

The new version differs by 5 commits .

  • bc482f4 7.1.1
  • baeb99b chore(package): update dependencies (#422)
  • 2d587d6 append code frame on parse error (#418)
  • e7c9a03 chore(package): update babylon to version 6.13.0 (#420)
  • 971c8d6 chore(package): update eslint to version 3.9.1 (#419)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Document newer ES features used in the library

The library uses a few newer ES features - one of which is the String.prototype.includes method (related: #112). It would be nice to document them, so that it's easier to polyfill them if needed.

Also might be related: #103.

An in-range update of babel-plugin-transform-runtime is breaking the build 🚨

Version 6.23.0 of babel-plugin-transform-runtime just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-runtime
Current Version 6.22.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-runtime is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ bitHound - Dependencies 2 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… continuous-integration/appveyor/branch AppVeyor build succeeded Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Strip indent having issues when using something like util.inspect

When I'm including data that was serialized using node's util.inspect function, stripIndent seems to be making some mistakes on how to handle the indent stripping. Here's the script and the output as an example:

'use strict';
const commonTags = require('common-tags');
const util = require('util');


const obj = {
	prop1: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
	prop2: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
	shape: {
		prop3: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
		prop4: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf'
	}
}

if (true) {
	if (true) {
		console.log(commonTags.stripIndent`
			Some firstline message
			Some secondline message
			${util.inspect(obj)}
		`);
	}
}

Actual output:

Some firstline message
        Some secondline message
        { prop1: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
prop2: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
shape:
 { prop3: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
   prop4: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf' } }
vagrant@dev:/opt/signal (alert-check-update)$ node scratch/data-test.js

Expected output:

Some firstline message
Some secondline message
{ prop1: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
  prop2: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
  shape:
   { prop3: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf',
     prop4: 'asdfasdfasdfsadfasdf asdfasdfasdfsadfasdf' } }

Support nested html

I've been learning about tagged templates and I discovered common-tags. It's so useful -- many thanks for it!

I was hoping that html might be able to handle nested, multi-line sections, such as you might produce with another html tagged literal. Then you could compose html and have the indenting magically work. But that doesn't seem to be the case.

Here's a test case. Would supporting something like this be at all feasible?

const { html } = require("common-tags");

test("renders nested HTML", () => {
  const fruits = ["apple", "banana", "kiwi"];
  const expected = `<!DOCTYPE html>
<html lang="en">
  <body>
    <ul>
      <li>
        <div>apple</div>
      </li>
      <li>
        <div>banana</div>
      </li>
      <li>
        <div>kiwi</div>
      </li>
    </ul>
  </body
</html>`;

  function renderFruit(fruit) {
    return html`
      <li>
        <div>${fruit}</div>
      </li>`;
  }

  const actual = html`
    <!DOCTYPE html>
    <html lang="en">
      <body>
        <ul>
          ${fruits.map(renderFruit)}
        </ul>
      </body>
    </html>`;

  expect(actual).toBe(expected);
});

An in-range update of babel-plugin-transform-runtime is breaking the build 🚨

Version 6.15.0 of babel-plugin-transform-runtime just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-runtime
Current Version 6.12.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-runtime is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… bitHound - Code No failing files. Details

  • βœ… bitHound - Dependencies No failing dependencies. Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-preset-stage-0 is breaking the build 🚨

Version 6.24.1 of babel-preset-stage-0 just got published.

Branch Build failing 🚨
Dependency babel-preset-stage-0
Current Version 6.22.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-preset-stage-0 is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ bitHound - Dependencies 4 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • βœ… codecov/project 100% remains the same compared to f651e9d Details

  • βœ… codecov/patch Coverage not affected when comparing f651e9d...66ecec5 Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of when is breaking the build 🚨

Version 3.7.8 of when just got published.

Branch Build failing 🚨
Dependency when
Current Version 3.7.7
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As when is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ bitHound - Dependencies 2 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

Release Notes 3.7.8: Unhandled rejection fixes
  • Fix unhandled rejection false positive in settle
  • Fix unhandled rejection events on IE
  • Make build work on Windows
Commits

The new version differs by 9 commits .

  • 5c0a9eb release: 3.7.8
  • 0768dd8 Emit unhandledRejection on Internet Explorer (+ fixes on Windows) (#496)
  • facc6ba Fix unhandled rejection warnings in when.settle (#493) (#494)
  • 8a7785a Make sure MutationObserver is used in Safari as well (#488)
  • f9fa814 Merge pull request #485 from iamstolis/microtime-dependency
  • 9cbecad Updating microtime dependency (so that microtime installs on Node 4 and 5)
  • 2fff98c Enabling Node 4 and 5 on Travis
  • ade6393 Merge pull request #480 from stevage/patch-2
  • 3d2b25f Correct promise.tap "equivalent" explanation

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of which is breaking the build 🚨

Version 1.2.12 of which just got published.

Branch Build failing 🚨
Dependency which
Current Version 1.2.11
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As which is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… bitHound - Code No failing files. Details

  • βœ… bitHound - Dependencies No failing dependencies. Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Post-process output of other tag functions?

Occasionally, it’d be nice if one could dedent the output of another tag function, like this:

stripIndent(String.raw)`
    abcdefg
`;

That could be achieved by making all functions behave differently if the first (and only) parameter is a function.

An in-range update of babel-register is breaking the build 🚨

Version 6.24.0 of babel-register just got published.

Branch Build failing 🚨
Dependency babel-register
Current Version 6.23.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-register is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ bitHound - Dependencies 2 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • βœ… codecov/patch Coverage not affected when comparing f651e9d...fce9043 Details

  • βœ… codecov/project 100% remains the same compared to f651e9d Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of micromatch is breaking the build 🚨

Version 2.3.11 of micromatch just got published.

Branch Build failing 🚨
Dependency micromatch
Current Version 2.3.10
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As micromatch is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… bitHound - Code No failing files. Details

  • ❌ bitHound - Dependencies 1 failing dependency. Details

Commits

The new version differs by 3 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

1.5.0 breaking changes

stripIndents now replaces multiple newlines with a single one.

console.log(stripIndents`
a
b

c
`);

1.4.0 output:

a
b

c

1.5.0 output:

a
b
c

use jsnext:main to expose modern JS syntax, pre-babel for 4.x

More information: https://github.com/rollup/rollup/wiki/jsnext:main

And then anyone doing a normal Node.js require, say in 4.x, would no longer be forced into loading babel-runtime into their production processes.

I was just about to recommend this library to my network, but that runtime dependency is a deal-breaker.

Really, I'd recommend that you babel down to lowest common denominator (ES5) to make it easier for users to webpack their components. The standard webpack/babel configuration excludes node_modules: https://github.com/babel/babel-loader#usage

Objects call their valueOf methods instead of toString methods.

When converting objects into strings that have a custom toString method, I've noticed the lib calls valueOf instead. I don't know if this is intentional, but it really is confusing if you aren't expecting this behavior.

console.log(stripIndents`
    ${obj} is cool!
`);

Assuming obj has a valueOf that returns "1" and a toString that returns "2", the valueOf gets called, which in normal template literals is not the case.

Fails to load under [email protected]

I'm using PhantomJS 1.9.8 to test my browserify build (partly because it's still the travis CI default and partly to make sure I'm not pulling in anything that'll blow up on older browsers) and common-tags does. I checked the repo and since it's building with babel I hoped that'd be "good enough" but it's apparently not. Any gut reaction to this issue before I pull things down and dig in further?

`source` doesn't seem to work when put into a new template literal?

Here is my current code:

function generateFruits () {
  const fruits = [
    {
      name: 'apples',
      quantity: 3
    },
    {
      name: 'oranges',
      quantity: 2
    }
  ]

  return source`
    Fruits
      ${fruits.map(f => `${f.name}: ${f.quantity}`)}
  `
}

If I do console.log(generateFruits()), I get the expected output:

Fruits
  apples: 3
  oranges: 2

However, if I create a variable called template and use generateFruits() inside of there, it doesn't seem to work:

const template = stripIndent`
  ${generateFruits()}
`

I thought that this would give the same output, but instead it seems to give this:

Fruits
apples: 3
oranges: 2

And if I remove the stripIndent, it gives this:

  Fruits
  apples: 3
  oranges: 2

Why does using generateFruits() inside a different template literal make it lose the indentation?

More generic name for `html` tag?

I came across this library via 2ality. Thanks for this great collection of problem solvers!

My main use is for the html tag - but my template contains JavaScript source code, not HTML. In fact the html tag is pretty useful while generating any block-structured code with correct indenting.

It looks a little strange and not so self-documenting to see JavaScript source inside a html tagged template. At present I just import it using something like import {html as js} from 'common-tags', but it also looks a bit odd seeing html there.

So, I was wondering if this tag could have a more generic name (or at least an alias) exported from the library itself?

Optionally escape inserted content

It’d be nice to have the option to escape inserted content (you’d only need to detect a prefixed dollar sign):

const name = '<Jane>';
console.log(html`Name: $${name}`);
    // Name: &lt;Jane&gt;

The function that escapes could be configurable. One simple implementation:

function htmlEscape(str) {
    return str.replace(/&/g, '&amp;') // first!
              .replace(/>/g, '&gt;')
              .replace(/</g, '&lt;')
              .replace(/"/g, '&quot;')
              .replace(/'/g, '&#39;')
              .replace(/`/g, '&#96;');
}

stripIndent with stripIndent'ed string inside doesn't strip some indents

Test case:

const stripIndent = require('common-tags').stripIndent;

const line1 = stripIndent`
    line1.0
    line1.1`;

console.log(line1);

const line2 = stripIndent`
    ${line1}
    line2.0`;

console.log(line2);

Output:

line1.0
line1.1
line1.0
line1.1
    line2.0

As you see, line2.0 isn't de-indented. I'm not sure if it's expected behaviour. If so, how can I achieve desired effect? Thanks for nice lib!

An in-range update of babel-preset-latest is breaking the build 🚨

Version 6.24.0 of babel-preset-latest just got published.

Branch Build failing 🚨
Dependency babel-preset-latest
Current Version 6.22.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-preset-latest is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… bitHound - Code No failing files. Details

  • ❌ bitHound - Dependencies 2 failing dependencies. Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • βœ… codecov/patch Coverage not affected when comparing f651e9d...5113446 Details

  • βœ… codecov/project 100% remains the same compared to f651e9d Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Source map error in common-tags when building with webpack

I feel a little bad posting this here, I'm not 100% convinced that common-tags is the problem, but it's the top of the stack trace, so here goes...

Occasionally our webpack build will start giving the following error:

 ERROR in ./node_modules/common-tags/lib/oneLine/index.js
    Module build failed: Error: /Users/joe/Code/lendinghome-treefuls/feature-1/node_modules/common-tags/lib/oneLine/index.js: original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.
        at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/source-map/lib/source-map-generator.js:276:15)
        at SourceMapGenerator_addMapping [as addMapping] (/Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/source-map/lib/source-map-generator.js:110:12)
        at /Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/babel-core/lib/transformation/file/index.js:467:27

It happens with or without, hot module reload enabled and in between builds without ANY changes to node modules. The only solution is to remove all node_modules folders and try again. This happens at least three or four times a day to multiple devs on our team.

The only reason I'm suspicious of this library is because if I remove all uses of the oneLine tag, everything works again. Once I revert that change, it breaks immediately. I've googled it, and it seems like lot's of people run into this error with various libs (see mozilla/source-map#304, webpack/webpack-sources#28 and webpack/webpack#6131). We do not use the libraries listed in these issues.

I don't have the time right now, but I'll try to see if I can reproduce this in a separate repo. I'm posting this right now to gather data and see if anyone has this issue with common-tags in the stack trace. Or maybe if the maintainers here have any thoughts on whether or not this library is the root cause.

Thanks!

EDIT: Thought I'd add that our app is being transpiled with babel-runtime 6.26.0, and regerator-runtime 0.11.0. We are currently on common-tags 1.4.0, but I still saw this same issue after updating to the latest. Also, our webpack build has multiple entry points, not all of which use common-tags. If I remove the ones that DO use it, the build succeeds. As soon as I put them back, it fails again with the same error.

An in-range update of rimraf is breaking the build 🚨

Version 2.6.0 of rimraf just got published.

Branch Build failing 🚨
Dependency rimraf
Current Version 2.5.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As rimraf is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ bitHound - Dependencies 2 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

Commits

The new version differs by 5 commits .

  • 5b661e4 v2.6.0
  • c09915f update tap
  • d53235d Make rimraf.sync 10000% more reliable on Windows
  • e8b10a7 Retry on EBUSY et al on non-windows platforms as well
  • 0fac5f7 Add --no-glob option to cli

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Remove `null` values from `html` output

Currently, the html tag produces invalid markup when a null value is encountered:

import {html} from 'common-tags'

const todos = [{
  task: 'some task',
  done: false
}, {
  task: 'other task',
  done: true
}]

html`
  <h1>Incomplete tasks:</h1>
  <ul>
    ${todos.map((t) => t.done ? null : `<li>${t.task}</li>`)}
  </ul>
`

Produces:

<h1>Incomplete tasks</h1>
<ul>
  <li>some task</li>
  null
</ul>

An in-range update of babel-cli is breaking the build 🚨

Version 6.22.0 of babel-cli just got published.

Branch Build failing 🚨
Dependency babel-cli
Current Version 6.18.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-cli is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… bitHound - Code No failing files. Details

  • ❌ bitHound - Dependencies 1 failing dependency. Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • βœ… continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • βœ… codecov/patch Coverage not affected when comparing f651e9d...e7f2d95 Details

  • βœ… codecov/project 100% (+0.00%) compared to f651e9d Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

source tag doubles newlines in certain circumstances

I think there's some kind of issue with interpolation/substitution with the source tag - for instance, if I do something like

const baz = "baz\nquux\ngarply";
source`
  Foo
  Bar

  ${baz}
`

where baz contains newlines, the result will have all the newlines within baz doubled:

Foo
Bar

baz

quux

garply

but I would have expected

Foo
Bar

baz
quux
garply

This only happens if the interpolation is preceded by a newline.

Interestingly, if I do something like

source`${baz}`

the newlines actually get turned into spaces, which is also not what I would have expected.

I think it has something to do with the fact that source blocks attempt to match the outer indentation level when you interpolate a variable? I.e.,

source`
  Foo:
    Bar
    ${baz}
`

becomes

Foo:
  Bar
  baz
  quux
  garply

Fix inconsistency in README: Code example for inlineArray uses Serial Comma, actual output is Non-Serial

https://github.com/declandewet/common-tags#commalistsand

^ shows the output
I like apples, bananas, and watermelons

Actual output
I like apples, bananas and watermelons

I'm not sure which you're intending to be the correct behavior.

Related:
If you do support Oxford comma, then you need to support:

"Foo and bar"
The current inline transformer with separator and conjunction options looks like it would only handle:
"Foo, and bar" with a comma.

An in-range update of regenerator-runtime is breaking the build 🚨

Version 0.10.2 of regenerator-runtime just got published.

Branch Build failing 🚨
Dependency regenerator-runtime
Current Version 0.10.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As regenerator-runtime is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • βœ… bitHound - Code No failing files. Details

  • ❌ bitHound - Dependencies 2 failing dependencies. Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

oneLine does not preserve multiple spaces within input lines

Its name and test suggest that it would ("reduces text to one line, replacing newlines with spaces").

For example the following is unexpected

oneLine`
  Preserve eg sentences.  Double
  spaces within input lines.
` === 'Preserve eg sentences.  Double spaces within input lines.'
// => false

An in-range update of babel-runtime is breaking the build 🚨

Version 6.20.0 of babel-runtime just got published.

Branch Build failing 🚨
Dependency babel-runtime
Current Version 6.18.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-runtime is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ bitHound - Dependencies 11 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Efficient way of eplacing a string in an external javascript file?

Let me start by saying this project looks awesome.

I need to replace a string inside a javascript file before sending it from a server.

var file = 'var test = ${var}' // or fs.createReadStream('my.js', 'utf8')

reply
      .header('Content-Type', 'application/javascript; charset=UTF-8')
      // replace placeholder in js file
      .send(file)

Would this be possible with this package? πŸ˜„

Thanks!

Why the NPM >=3.0.0 requirement?

I just noticed in a stylelint/stylelint Travis CI job the warning:

npm WARN engine [email protected]: wanted: {"node":">=4.0.0","npm":">=3.0.0"} (current: {"node":"4.4.7","npm":"2.15.8"})

In your readme requirements: https://github.com/declandewet/common-tags#requirements πŸ‘

"NPM (v3.0.0+ highly recommended) (this comes with Node.js)"

When NodeJS 4.x is installed with NVM as Travis CI does it does not install the latest NPM 3.x.x branch, the 2.x.x branch is used, you can also see this in your own 4.x Travis job:
β€’ https://travis-ci.org/declandewet/common-tags/jobs/139596870#L123

2.28s$ nvm install 4
Downloading https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-x64.tar.xz...
######################################################################## 100.0%
Now using node v4.4.5 (npm v2.15.5)
...
$ node --version
v4.4.5
$ npm --version
2.15.5
$ nvm --version
0.31.0
install
8.15s$ npm install 

The NodeJS 5.x branch doesn't have this issue as it uses NPM 3.x for example:
β€’ https://travis-ci.org/declandewet/common-tags/jobs/139596869#L123

NodeJS 4.x.x is the LTS (Long Term Support) NodeJS release: https://github.com/nodejs/LTS/blob/master/README.md

NPM 2.x.x is the LTS NPM release: https://github.com/npm/npm/wiki/Roadmap#tactical-roadmap

So, does common-tags really require NPM 3.x.x? Would you consider removing the 3.x.x requirement? It appears to work fine with common-tags and stylelint using NPM 2.x.x

Feature Proposal: Use a tag as a transformer plugin

It's possible to use a template tag as a transformer by latching on to it's transformers property so we can effectively do this:

import {TemplateTag, stripIndent} from 'common-tags'

const upcaseTransformer = () => ({
  onEndResult (endResult) {
    return endResult.toUpperCase()
  }
})

// focus less on the implementation, more on how we're passing `stripIndent` as if it were
// a transformer plugin
const upcase = new TemplateTag(stripIndent, upcaseTransformer)

Generate built files for CDN use

Awesome project here! I had just finished reworking a bunch of examples for Netlify CMS using stripIndent when I realized there's no way to "just use it" via a CDN like unpkg.com. Have you considered providing built files?

support simple string

I really like using this pkg, and I really need sometimes to use the same great functions for strings,
currently I do oneLine([someString])

Can you please add support for strings so we could do oneLine(someString)?
Thanks

stripIndent removes trailing new line at end of string

let expectedOutput = stripIndent`
            .foo {
              color: red; }

            .foo {
              color: yellow; }

            .foo {
              color: green; }

            `

Output:

      .foo {\n  color: red; }\n\n.foo {\n  color: yellow; }\n\n.foo {\n  color: green; }

Expected Output:

      .foo {\n  color: red; }\n\n.foo {\n  color: yellow; }\n\n.foo {\n  color: green; }\n

My current workaround:

let expectedOutput = stripIndent`
            .foo {
              color: red; }

            .foo {
              color: yellow; }

            .foo {
              color: green; }
            replace
            `
expectedOutput = expectedOutput.replace('replace', '')

An in-range update of which is breaking the build 🚨

Version 1.2.13 of which just got published.

Branch Build failing 🚨
Dependency which
Current Version 1.2.12
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As which is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ bitHound - Dependencies 3 failing dependencies. Details

  • βœ… bitHound - Code No failing files. Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

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.