Comments (4)
I think I came across a similar issue. The problem, I think, is that if you have some interpolated values that don't have any leading whitespace, that becomes the minimum whitespace. Then, stripIndent
does also include the trim transformer, so the first line gets trimmed of the leading whitespace, but all other lines are untouched.
This is a little surprising to me, because I expected template tags to operate on the template literal before interpolation, rather than not after, but I haven't fully understood how this stuff all works yet.
from common-tags.
Aha! In this case, you're actually meant to use the html
tag which does handle embedded newlines.
This tag is also aliased to source
and codeBlock
, which make more sense to me, since personally I'm not writing HTML here.
from common-tags.
Hi, I can confirm that the issue is there in v1.4.0. I can't check right now whether it was fixed in #114, but will do so later today. In any case, a version with a fix should be released in a matter of days - keep your fingers crossed 🤞
from common-tags.
@ibrahima is right - "fixing" stripIndent
would turn it into source
, so I guess the only thing that's not working here is the naming (one of the unsolved problems of computer science 😉). I'll be adding a note about this particular behavior to the docs.
from common-tags.
Related Issues (20)
- Objects call their valueOf methods instead of toString methods. HOT 2
- Generate built files for CDN use HOT 3
- Support nested html HOT 4
- Efficient way of eplacing a string in an external javascript file? HOT 1
- Could you please update to 2.9.0 HOT 2
- [Feature Request] Add a way to intentionally insert line break inside a `oneLine` HOT 10
- ESM support (type=module + exports={}) HOT 2
- TypeScript definitions HOT 2
- Set the minimal supported node version to 10
- Rewrite to TypeScript HOT 4
- Update all packages
- `stripIndent` not stripping 1st line of variables HOT 1
- `html` behaves unexpectedly when there is no indent
- Fix TypeError of `stripIndent` when use invalid use of octal escape sequences in template strings
- What up with the declandewet/common-tags repo? HOT 5
- `codeBlock` breaking change adds newlines HOT 6
- Interpolated / nested literals
- `commaListsAnd` returns undefined values when using function format
- New tag defaultEmpty
- Common-tags is not tree shakeable by Webpack becasue sideEffects: false is missing in package.json HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from common-tags.