Hands-On Full Stack Web Development with Aurelia
上QQ阅读APP看书,第一时间看更新

Generating custom resources

Aurelia, like many JavaScript frameworks, allows you to create reusable components that help you avoid writing duplicated code, reuse your component in multiple parts of your app, and also export them as plugins to reuse them in other projects.

Aurelia allows you to generate the reusable pieces of code utilizing the following templates:

  • Components
  • Custom elements
  • Custom attributes
  • Binding-behaviors
  • Value-converters

These templates are all located in our project root folder in the aurelia_project/generators folder. For example, the following command generates a custom Aurelia element:

au generate element my-reusable-element

The source code will be generated in the src/resources/{type} folder depending on the type you selected.

Each type will be discussed in the following chapters, so don't feel bad if you don't understand the differences between them. Keep reading my friend! :)