Friday, November 27, 2026
HomeJavaScriptCheck out the Template Tag Codemod

Check out the Template Tag Codemod


One of many pillars of Ember’s upcoming Polaris version is Template Tag. Many groups are already writing their elements this manner and having fun with the improved developer expertise. The Template Tag RFC is presently within the “Launched” standing, and can attain “Beneficial” as soon as we’re happy that we’ve adequate documentation and polish.

To make it simpler for all groups to undertake Template Tag, we have created @embroider/template-tag-codemod. The purpose of the codemod is fully-reliable conversion to the brand new format.

This weblog put up is a name to check out the codemod. Even should you’re not able to commit but to utilizing Template Tag in your app, you may strive operating the codemod in your app to see what outcomes you get and report bugs that get in your manner.

The super-short model of the directions should you simply need to give it a strive are:

  1. Be certain that you haven’t any uncommitted modifications, as a result of we’re about to begin mutating all of your information!
  2. Run npx @embroider/template-tag-codemod.
  3. (Elective however extremely really helpful) Use prettier (with GJS assist enabled) to make the outcomes fairly.
  4. (Elective however extremely really helpful) use npx @embroider/template-tag-codemod merge-history --help

The default habits will try and convert the whole lot in your app, and it’ll goal essentially the most forward-looking output format.

Learn the --help and the entire directions within the README to:

  • restrict which information shall be transformed :
  --renderTests false --routeTemplates false --components app/elements/only-these-ones/**/*.hbs
  • get output that’s extra appropriate with Ember < 6.3.0:
  --nativeRouteTemplates false --nativeLexicalThis false
  • get output that makes use of imports from the app’s module namespace as an alternative of relative paths import Bar from 'my-app/utils/bar';; that is required within the basic builds:
  --relativeLocalPaths false
  • produce TypeScript GTS information slightly than JavaScript GJS information in instances which are ambiguous between these two decisions:
  --defaultFormat gts
  • customise the naming decisions for imported elements/helpers/modifiers:
  --renamingRules ./your-rules-here.mjs

Why is that this codemod below the @embroider namespace?

As a result of Template Tag Codemod is powered by the identical backward-compatibility infrastructure that we created in Embroider to mean you can undertake fashionable construct tooling. If you construct an app with Embroider, Embroider must determine, find, and synthesize import statements for all of the elements, helpers, and modifiers that you simply use in your conventional handlebars templates. The Template Tag Codemod does precisely the identical factor, besides as an alternative of repeating that course of each time you do a construct, we will do it once-and-for-all and commit the ensuing GJS (or GTS for TypeScript customers) information immediately into your challenge. Consequently, switching to Template Tag can lead to improved construct efficiency for apps which have already adopted Embroider.

Please report points right here and ask questions within the #dev-embroider channel on the neighborhood Discord.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments