Components
Last updated
Last updated
EJS supports custom, reusable components by leveraging the VueJS library. A component is simply a self-contained triad of HTML, JavaScript, and CSS that can be represented by a custom HTML tag.
Check out the for more information on using components.
EJS provides on-the-fly code-splitting and compilation of VueJS components defined in a single file. This allows the component author to include the entire component definition in one file.
Single-file components are defined using simple HTML syntax in a file with a .vue
extension.
EJS does not currently support scoped or pre-processed CSS in component definitions.
All instance methods are available as properties on this
within a component and are prefixed with the dollar symbol ($).
The EJS environment makes several instance methods available within component definitions. These methods provide access to core functionality, such as and .
The $getRoute() instance method returns a compiled route object, representing the currently matched in the address bar.
The compiled route object is useful for looking up matched values, reading from the route definition, and determining the relative position in the .
The $generatePath instance method makes it possible to the absolute path to any using its name and . Using this method ensures all links are automatically updated whenever a route is changed.
Alternatively, you may use a within your component templates to generate routes declaratively.
The $translate instance method provides access to translations from the library. It accepts the identifier for a and an object containing key-value pairs representing variables to replace in the processed string.
The translations are performed based on the currently set .
The $setLocale instance method is used to set the . Changing the active locale automatically loads the appropriate and performs all necessary translations.