简体   繁体   中英

Can I put css and html markup inside a js flashify message

I am working on a project built with sails.js. I have taken over this project and I'm not very familiar with sails.js yet so I'm still getting my bearings.

From what I can see, the sails package includes flashify and the previous developer is using it in several places to display notification. The client wants a few of those notifications to be a little fancier than just the default popup and I'm wondering if it's possible to somehow restyle the flashify popup and add html markup to it.

Here's one instance where a message is initiated:

if(!req.isAuthenticated()){
    req.flash("error", "Please log in");
    return res.redirect('back');
}

I have tried adding html tags to the message string, escaping them and taking them out of the string quotes but none of that worked. Is it possible at all?

A couple of things:

  1. Sails uses connect-flash by default. Your project might actually be using Flashify, but if you don't actually see require('flashify') in the code, it probably isn't.

  2. More importantly, both connect-flash and flashify are back-end packages that just save messages into the session so that they survive between requests. They have nothing to do with the actual display of the message, which is handled in your template (most likely an .ejs file in the views folder). If there's a popup, then that's being created and launched in that template, so that's where you'd want to style it. Take a look at the Sails views documentation for more about view rendering, and also this question about rendering flash messages in a view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM