egg-flash
flash messages for egg
Install
$ npm i egg-flash --save
Usage
// {app_root}/config/plugin.jsexportsflash = enable: true package: 'egg-flash';
Use ctx.flash()
in your controller
// {app_root}/app/controller/home.jsexportsindex = async { ctx; ctx;}; exportsaddFlash = async { ctx; ctx;};
Access the messages in your views via locals.messages (Nunjucks in this case):
{% if messages.info %}
{% for message in messages.info %}
<div class="message info">
<span>{{ message }}</span>
</div>
{% endfor %}
{% endif %}
Questions & Suggestions
Please open an issue here.