惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
B
Blog
博客园 - Franky
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
宝玉的分享
宝玉的分享
小众软件
小众软件
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
量子位

Ember.js Blog

Ember 7.0 Released Announcing the Official TypeScript Types Public Preview Accessibility Working Group Update The 2020 Ember Roadmap Countdown to The New Year - Built-in Addons Countdown to The New Year - Ember Exam Countdown to The New Year - Ember Code Snippet Countdown to The New Year - Ember Changeset Countdown to The New Year - Ember In Viewport Countdown to The New Year - Ember CLI Update Countdown to The New Year - Ember Template Invocation Location Countdown to The New Year - Ember CLI TypeScript Countdown to The New Year - Ember Bootstrap and Ember Paper Countdown to The New Year - Ember CSS Modules Countdown to The New Year - Ember Mapbox GL Countdown to The New Year - Ember Shepherd Countdown to The New Year - Ember Template Lint Countdown to The New Year - Ember Composable Helpers Countdown to The New Year - Ember Leaflet Countdown to The New Year - Ember Intl Countdown to The New Year - Ember Test Selectors Countdown to The New Year - Ember Power Select Countdown to The New Year - Ember Simple Auth Countdown to The New Year - Ember SVG Jar Countdown to The New Year - Ember Page Title Countdown to The New Year- Ember A11Y Testing Countdown to The New Year - Ember CLI Sass Countdown to The New Year - Ember Animated Countdown to The New Year - Ember Auto Import Countdown to The New Year - Ember Concurrency
Countdown to The New Year - Ember Angle Brackets Codemod
2019-12-09 · via Ember.js Blog

– By Ryan Mark

This is the ninth in our DecEmber series–"Countdown to The New Year: 31 Days of Ember Addons". We plan to highlight a new addon each day until the new year, and we hope you'll join us for the fun!

Day 9

Until recently, converting Ember templates to use Angle Bracket invocation was a tiresome and manual task. With the latest version of ember-angle-brackets-codemod, you get a smarter, more complete codemod to change your templates in a flash!

What It Does

Before Angle Bracket invocation, nearly every template construct in Ember was invoked using Handlebars {{doubleCurly}} syntax. This made differentiating between components, helpers, and plain values incredibly difficult. Angle Brackets alleviate most of this ambiguity. But what if you wanted to change every double curly component invocation to Angle Brackets? That task could take forever (especially if you cant reliably tell the difference between everything in your templates)! The Angle Bracket Codemod eases the transition in a few steps:

  1. It visits a URL of your app that is supplied as a command line argument
  2. A small bit of code is injected into the context of the app.
  3. The code identifies the app's components and their properties, as well as all the helpers. This includes those in addons!
  4. Given all this information, the codemod quickly changes all the apps templates preserving most of the space and indentation.

Here is an example of typical conversion:

Before

{{site-header user=this.user class=(if this.user.isAdmin "admin")}}

{{#super-select selected=this.user.country as |s|}}
  {{#each this.availableCountries as |country|}}
    {{#s.option value=country}}{{country.name}}{{/s.option}}
  {{/each}}
{{/super-select}}

{{ui/button text="Click me"}}

After

<SiteHeader @user={{this.user}} class={{if this.user.isAdmin "admin"}} />
<SuperSelect @selected={{this.user.country}} as |s|>
  {{#each this.availableCountries as |country|}}
    <s.option @value={{country}}>
      {{country.name}}
    </s.option>
  {{/each}}
</SuperSelect>

<Ui::Button @text="Click me" />

Additionally, the codemod has a number of options that can be configured. The codemod can be adjusted to skip certain helpers, avoid changing built-in components {{link-to}}, {{input}} and {{textarea}}, or skipping files for conversion altogether.

Why I Like It

Codemods are the best, especially if they are smart! They save a significant amount of time and they are typically better than manual intervention. Until a few months ago, running this codemod and the changes it made were entirely based on a set of heuristics. The codemod was good but it often made mistakes, requiring an exhaustive amount of human input. Today the codemod can intelligently convert templates to Angle Bracket invocation with exceptional precision, often with few to no errors. This allows teams to opt-in to the future in an instant instead of wasting precious cycles.

Do you use this codemod? Or one like it? We'd love to hear about Ember codemods that bring you joy!