Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate empty/notEmpty in Marko v3 #357

Closed
patrick-steele-idem opened this issue Aug 19, 2016 · 2 comments
Closed

Deprecate empty/notEmpty in Marko v3 #357

patrick-steele-idem opened this issue Aug 19, 2016 · 2 comments
Assignees
Labels
type:feature A feature request
Milestone

Comments

@patrick-steele-idem
Copy link
Contributor

patrick-steele-idem commented Aug 19, 2016

The builtin empty/notEmpty helpers will be removed in Marko v4 and will be deprecated in v3 (with console warning).

If still needed, these helpers can still explicitly be imported:

<script marko-init>
var empty = require('marko/helpers/empty');
var notEmpty = require('marko/helpers/notEmpty');
</script>

Alternatively, you can simply check the array length or ensure that a string is not "falsey".

Why?

The empty/notEmpty helpers were automatically being added to every compiled template. While they can be helpful, we feel it is better if the developer explicitly imports only the exact helpers that your code depends on for improved modularity. Also, when adding support for inline marko templates we found that these empty/notEmpty helpers could conflict with other JavaScript code since all static code/imports are added at the top of the JavaScript file.

@briceburg
Copy link
Contributor

briceburg commented Oct 12, 2016

Is it possible to see a workaround for this outside of

<script marko-init>
var empty = require('marko/helpers/empty');
var notEmpty = require('marko/helpers/notEmpty');
</script>

I'm using:

<if(data.commits && data.commits.length)>
  ...
</if>

@patrick-steele-idem
Copy link
Contributor Author

@briceburg I suppose one possibility would be to introduce a new option in marko.json to opt-in for the empty/notEmpty helpers, but I don't think it is a good idea to go there. Personally, I would just use <if(data.commits && data.commits.length)> instead of a helper. If you have any other thoughts or ideas please share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature A feature request
Projects
None yet
Development

No branches or pull requests

2 participants