Question: Create reusable partial view in sails js


Create reusable partial view in sails js

Answers 0
Added at 2016-12-25 01:12

I need to create a reusable "featured listings" ui component in my sails js app. I'm using the default ejs template engine. Basically this "featured listings" ui component finds the first 5 featured listings and displays them. This ui component will be re-used in several parts of the app, for example in sidebars, admin panels, etc.

According to what I've read I believe a service could work for this. The idea is not to have to query the database in every controller and pass the result to every view which has "featured listings". The "featured listings" is an example, this could be a complex menu as well.

If you are familiar with Yii2 framework, this should be similar to a widget.

What would be the best practice in Sails js to achieve this? I thought of a service that returns an ejs template, but I don't know if this is the right approach or how to implement it. Any help is welcome. Thanks in advance.

Answers to

Create reusable partial view in sails js

Source Show
◀ Wstecz