balderdashy / balderdashy/sails

SailsJS EJS filters not working

Open
#6,945 2 comments 0 reactions 0 assignees View on GitHub
helpful info or workaround question v1.x
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Node version**: 12.13
**Sails version** _(sails)_: 1.2.3
**ORM hook version** _(sails-hook-orm)_: 2.1.1
**Sockets hook version** _(sails-hook-sockets)_: 2.0.0
**Grunt hook version** _(sails-hook-grunt)_: 4.0.0
**Uploads hook version** _(sails-hook-uploads)_:


Hi Guys.
I am trying to create a filter for usage inside EJS templates.
the way described in the docs and issues related to versions 0.11 and 0.12 and none related to 1.x version of sails. i tried the methods and procedures in the old versions and yet it does not work in 1.2.3 version of sails.

what i need is to define a helper which successfully done and added the corresponding module and exported as it should with **sync: true** attribute in the module.exports.

the **/api/helpers/timm-text.js** :
```javascript
module.exports = {
friendlyName: 'Trimm text',
description: '',
inputs: {
txt:{
type:'string'
},
num:{
type:'number',
defaultsTo:50
}
},
sync : true,
exits: {
success: {
description: 'All done.',
},
},
fn: function (inputs,exits) {
sails.log.debug('trimming ');
return exits.success(inputs.txt.slice(0,inputs.num));
}
};
```
and in my template am trying to access it as such :
```html

<%= movie.plot | filters.trimmText %>


```
and yet with no luck as it just outputs
```html

0


```

Any idea how to use filters in the current version ?

Much Regards

Contributor guide

Open the contributing guide

Research direction

Start with /api/helpers/timm-text.js and the EJS expression using filters.trimmText. Compare the helper's sync configuration and return value with the documented Sails 1.2.3 template usage, then verify that the template renders the trimmed plot text instead of 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.