Skip to content

Instantly share code, notes, and snippets.

@saravanak
Last active April 11, 2020 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saravanak/8f0a158d5727435fdda9c6ea680925e8 to your computer and use it in GitHub Desktop.
Save saravanak/8f0a158d5727435fdda9c6ea680925e8 to your computer and use it in GitHub Desktop.
Use component colocation Since Ember 3.13.
#!/bin/bash
# to be executed in the root directory of an Ember project.
# What: After working on an Ember codebase with pod structure, I found it intuitive to use co-located components.
# Since Ember 3.13, we have support for component co-location.
# This script moves all component templates to their respective component locations.
# YMMV:
# 1. Leaves empty directories on the `templates` folder
# 2. Close your project files in the editor before doing this.
# 3. You are using SCM, and you've committed/stashed your changes right ?
for file in `find app/templates/components -type f`
do
component_location=$(echo $file | sed 's/templates\///')
mv $file $component_location
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment