Mantra how-to guide

Locating Mantra projects assets easily

Mantra component files are named so that they can be found easily with any IDE

08-Mar-2022
A  A  A 

Mantra assets files, like views, blocks, APIs, middlewares, etc., should follow some naming conventions, and this is not a simple whim.

Given a component of name "seo", as an example, their components assets should be named like the following, as you can read at the documentation:

  • api.seo.js, for components APIs definitions and their handlers.

  • view.seo.js, for components views handlers.

  • block.seo.js, for blocks rendering handlers.

  • command.seo.js, for console commands implemented by the component.

  • middleware.seo.js., for middlewares

, and so on.

Besides this, the organization of a component is expected by Mantra to be done with specific folders, like:

  • /controllers, to locate all api, view, blocks, etc. handlers and component logic.

  • /ui/views, to locate all HTML views.

  • /ui/blocks, to locate all HTML blocks,

, etc.

This is, the name of the assets is important, not only to have them well orgnized, but to find them easily.

As developer, I always say that to be productive, you must keep your hands on the keyboard as much time as you can...

Given the components files follow some name conventions, then you can find them with the serach utility of your working IDE.

As an example, in Visual Studio Code, with Ctrl+P, you open the command utility to find assets.

If you need to open the API handlers for "seo" component, you just need to type "api.s...", automatillaly, the IDE will show all files starting with "api.s", so you can open "api.seo.js" in one or two seconds.

If you get used to work in this way, your productivity as developer will be extraordinary.