Releases: zspecza/common-tags
v1.8.2
v1.8.1: The "anti-takeover" one
The creator of the package changed the handle from declandewet
to zspecza
, and for a while GitHub was redirecting from the old repo to the new one. This changed with the "takeover" of the original user handle by a random person, and so in this release all the links in package.json are updated to include the new handle.
The next step!
This is a pre-release. Please help the development of common-tags by testing the common-tags@next version.
Version 2.0.0 is coming. Before it is released however, there are some things to be done - eg. the documentation needs to be rewritten properly for clarity. Maybe the package will be also rewritten into TypeScript? Who knows.
Breaking changes
TemplateTag
no longer detects whether the argument is a function and subsequently calls it. This may have been a bit convenient, but at the cost of code clarity, and it was also adding extra complication to the core function that should be as lean as possible: (declandewet/common-tags@0c1c971)- Arguments in transformers are now checked on initialization as opposed to inside the hooks. This makes errors detectable earlier (declandewet/common-tags@1811baa)
New stuff
createTag
is introduced as a replacement forTemplateTag
. The days of addingnew
each time you want to combine some tags are over (declandewet/common-tags@74d1076)- Each of the hooks (
onString
,onSubstitution
,onEndResult
) now gets and additional argument:context
. You can initialize its value in the newgetInitialContext
hook. This replaces the previously suggested practice of doing something like assigning tothis
in a hook. For more insight I recommend reading the tests in the linked commit (declandewet/common-tags@c17c2f0) - A new tag is added:
id
. It just returns whatever it receives. Again, for more examples for now look into tests in the following commit (declandewet/common-tags@52120bb) - Tags are now composable; previously this feat was impossible, as tags are functions and would've just been called. After the breaking change you can stuff other tags inside
createTag
without a problem (declandewet/common-tags@e393195) - Smart trimming was introduced as a remedy to a long-standing issue and is now used in
stripIndent
andstripIndents
(https://github.com/declandewet/common-tags/pull/165) - Nesting code inside other code when using
html
(akasource aka
codeBlock`) should not cause nasty surprises anymore (https://github.com/declandewet/common-tags/pull/182)
Deprecations
- As a result of the introduction of
createTag
,TemplateTag
is now soft-deprecated. That means you can still use it, but it will print a helpful message that will guide you to the new API (declandewet/common-tags@3ad1946)
v1.8.0
Bug Fixes
- Previously
valueOf
was called on objects in templates beforetoString
- now the order is in line with the spec (#144)
Plumbing
babel-plugin-transform-runtime
was removed as a dependency and as a resultbabel-runtime
is not necessary to usecommon-tags
any more (that meanscommon-tags
is dependency-free!) (#148)common-tags
is now rolling up into a neat bundle that you can get at unpkg. This makes it even easier to get started with this library! (#150)- Dev dependencies were updated (no changes to the actual code) (#149)
v1.8.0-rc.1
This was a test release to check if common-tags will register properly with unpkg.com.
v1.7.2
v1.7.1
v1.7.0
New Features
onString
onString
- transformers now accept an onString
method which runs on each part of the template literal that is not marked as a substitution (i.e. not inside "${}").
replaceStringTransformer
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.