Giter Site home page Giter Site logo

flash's People

Contributors

gluxon avatar jonathanong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flash's Issues

Feature request: TypeScript support

Hello world,

I would like to request a feature: TypeScript support.

I am going to to try to pull together a pull request if I can.

Thanks!

Flashes in twig

Hi, I have a problem with flashes in twig. I want pop stack of flash and write messages to template. For pop stack i use shift() like written in doc. But it's not works. Twig not support while loop, only for with syntax for <i> in <source>. Useless for pop flash stack.

{% for alert in flash.shift() %}
    <div class="alert alert-{{alert.type}} alert-dismissible fade show general-alert" role="alert">
      {{alert.message}}
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
{% endfor %}

How I solve this problem?

The value of a little advice

use while message = flash.shift() get value too cumbersome。
Some values are not my concern
I just want error_message value
Whether this can be req.flash('message') ?

I modified code
after flash('message') the 'message' be delete, no need to manually shift.

function push(type, msg) {
  var res = this.res || this;
  var locals = res.locals.flash;
  if(!msg){
      if(typeof type === 'string' && locals.length){
          for(var i = 0, l = locals.length; i < l; i++){
              if(locals[i]['type'] === type){
                  msg = locals[i]['message'];
                  locals.splice(i, 1);
                  return msg;
              }
          }
      }
      return;
  }
  msg = {
    message: msg,
    type: type
  }

  var messages = res.locals.flash
  // do not allow duplicate flash messages
  for (var i = 0; i < messages.length; i++) {
    var message = messages[i]
    if (msg.type === message.type && msg.message === message.message) return this
  }
  messages.push(msg)
  return this
}

the flash session not to be expired

Hello,
I have this session

app.use(session({ secret: 'changeme' , cookie: { secure: false,  maxAge: new Date(Date.now() + 3600000), } , resave:false, saveUninitialized:false, store: new SkinStore(db)  }));

when using flash it will stuck on the session and not to be expired !
should I destory the flash session manually

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.