Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 15 23:18

    shadowtime2000 on npm_and_yarn

    (compare)

  • Jun 15 23:18

    shadowtime2000 on master

    chore(deps): bump postcss from … Merge pull request #124 from et… (compare)

  • Jun 15 23:18
    shadowtime2000 closed #124
  • Jun 15 16:43
    dependabot[bot] labeled #124
  • Jun 15 16:43
    dependabot[bot] opened #124
  • Jun 15 16:43

    dependabot[bot] on npm_and_yarn

    chore(deps): bump postcss from … (compare)

  • Jun 15 16:42

    shadowtime2000 on master

    chore: bump deno std chore: bump deno std chore: remove deno_dist and 7 more (compare)

  • Jun 15 16:42
    shadowtime2000 closed #117
  • Jun 15 16:37
    shadowtime2000 closed #107
  • Jun 15 16:37
    shadowtime2000 commented #107
  • Jun 15 16:35
    shadowtime2000 closed #114
  • Jun 15 16:35
    shadowtime2000 commented #114
  • Jun 15 16:33
    shadowtime2000 commented #122
  • Jun 15 16:32
    shadowtime2000 labeled #122
  • Jun 15 16:32
    shadowtime2000 labeled #122
  • Jun 15 09:47
    patarapolw edited #123
  • Jun 15 09:38
    patarapolw edited #123
  • Jun 15 09:37
    patarapolw edited #123
  • Jun 15 09:37
    patarapolw opened #123
  • Jun 15 08:33
    patarapolw edited #122
shadowtime2000
@shadowtime2000
@LeanKhan Embedded means instead of it's own kind of language, within delimiters it is the same language that is controlling how the template renders inside the template
shadowtime2000
@shadowtime2000
like how we have js inside the delimiters
maybe it could be different types of template engines, basically differentiates embedded and logic less
shadowtime2000
@shadowtime2000
@LeanKhan I just did a small post about embedded js template engines https://eta.js.org/blog/what-is-embedded-js-template-engine - hope it helps you understand :)
Emmanuel Segun-Lean
@LeanKhan
Okay just read it hehe. It helps thank you. Aren't there embedded template engines for other languages besides js? And the definition also applies to them. Like erb for Ruby
@shadowtime2000 also, can you show examples from other languages perhaps. Or the difference between embedded ones and those that are not embedded?
shadowtime2000
@shadowtime2000
Cool! I mainly develop with JS/TS so I don't know much about those, but I can defininetly try to show an example of the difference between embedded ones and non embedded ones
Emmanuel Segun-Lean
@LeanKhan
Alright @shadowtime2000 well done 👍
dtrikannad
@dtrikannad
Do you guys have any samples of using flash messaging with eta?
shadowtime2000
@shadowtime2000
@dtrikannad What do you mean by flash messaging?
dtrikannad
@dtrikannad
thank you @shadowtime2000, I'm using eta with express-flash. It is a mechanism that allows me to save messages throughout the code and present them to the user on the next pages...is there another mechanism that allows me to do this? It would appear that it works just fine if I don't call render
Emmanuel Segun-Lean
@LeanKhan
@dtrikannad hey, i use "express-flash-message" note the name. So after creating a flash message and redirecting, you can add an if condition to check if there are any messages at all, then render them.
@dtrikannad you can even have them in a separate partial. Then you can also use them with a css framework that has alert components. You can also choose to use either cookie-sessions or regualr sessions. Hope this helps?
dtrikannad
@dtrikannad
Thank you @LeanKhan! That library does work with eta, but it doesn't allow me to have simultanous messages across multiple keys. For example, I cannot have an 'Info' and 'Success' message at the same time.
dtrikannad
@dtrikannad
This is why I was looking at the "express-flash" library
Emmanuel Segun-Lean
@LeanKhan
@dtrikannad you can actually, but youll juat have to repeat the statement that creates the flash messages. You can also use "Express-flash" however, it was not working well for me.
Emmanuel Segun-Lean
@LeanKhan

This is how I do it:


In my route... maybe after a login:
await req.flash('error', 'Something bad happened');
await req.flash('info', 'idk mehn, something happened sha');
await req.flash('success', 'Something good happened');

// bonus: I have this block in an app.use
// middleware so it captures all alerts for all routes

res.locals.alerts = {
    info: await req.consumeFlash('info'),
    error: await req.consumeFlash('error'),
    success: await req.consumeFlash('success'),
};

Then in your template:
<% alerts.forEach(function(alert){ %>
    <div>
     <%= alert.message %>
    </div>
<% }) %>

You can come up with something better that fits for usecase tho

Of course you add the necessary checks and validations
dtrikannad
@dtrikannad
@LeanKhan hmmm...that didn't work for me before...gonna try again...thanks for the tip! :)
dtrikannad
@dtrikannad
@LeanKhan I tried again, but the first consumeFlash works, but all subsequent consumeFlash calls return nothing...any ideas what could be causing that?
dtrikannad
@dtrikannad
@LeanKhan can you share which version of express-flash-message you're using? I've stepped in to the 2nd consumeFlash and req.session.flashMessage object is null. It gets nullified after the first consumeFlash call. On the first call, req.session.flashMessage contains all the messages, but once it returns, it seems to clear them all out and sets that object to null. any ideas? I'm using the latest 2.0.0
I'm using express-session for my session....here is my code:
dtrikannad
@dtrikannad
let sessionStore = new session.MemoryStore;
const sessionConfig = {
    secret: '[secret goes here]',
    name: 'appname',
    resave: true,
    saveUninitialized: true,
    store: sessionStore,
    cookie : {
      sameSite: 'strict', // THIS is the config you are looing for.
      maxAge: 60000
    },
    secure: false
  };
  app.use(session(sessionConfig));
dtrikannad
@dtrikannad
I wasn't able to get express-flash-message working, but I was able to get express-flash working just fine...thanks for suggesting that...after some trial and error, i was finally able to get express-flash to work just fine.
Emmanuel Segun-Lean
@LeanKhan
@dtrikannad they will return nothing if you previously didn't create any flash message. Did you do req.flash for the other messgae types? "Info", "success"?
@dtrikannad okay, you got express-flash to work? Nice one 👍
Simon Layfield
@simonlayfield
Hello :wave:
Just picked up Eta for something I'm working on so thought I'd tune in.
Simon Layfield
@simonlayfield
I was wondering if anyone who uses the eta-vscode extension for language support in vscode would be able to tel me which version of vscode they're using. It seems it's incompatible with my version (1.45.1).
dtrikannad
@dtrikannad

Anyone know how to call my own functions from within the template. For example, I have a library I've created a function in my utils.js file called exports.helloworld = (req, res) => { return 'Hello World'; }

how can I call helloworld() from within the template?

dtrikannad
@dtrikannad
nevermind...i did something like
        return res.render('pages/organization', {
          user: req.user,
          title: 'My Organizations',
          organizations: orgDetails,
          events: events,
          errorMessages: await req.flash('error'),
          infoMessages: await req.flash('info'),
          successMessages: await req.flash('success'),
          warningMessages: await req.flash('warning'),
          dtFormat: require('dateformat')
        });
where dtFormat takes in the require statement directly and that worked.
shadowtime2000
@shadowtime2000

I was wondering if anyone who uses the eta-vscode extension for language support in vscode would be able to tel me which version of vscode they're using. It seems it's incompatible with my version (1.45.1).

@simonlayfield :wave: Hey, I created eta-vscode. I am running 1.54.3 and it seems to work fine for me

Simon Layfield
@simonlayfield
@shadowtime2000 Hey! :wave: Oh, right. Ermm. I'll check again!
Simon Layfield
@simonlayfield
@shadowtime2000 I updated to 1.54.3 and it works. Thanks!
Simon Layfield
@simonlayfield
What would be the best way to access an environment var from within an eta template without having to pass it down for every view render? Is there a way to set a var globally for all views?
Simon Layfield
@simonlayfield
Oh, silly. Used res.locals.
shadowtime2000
@shadowtime2000
@/all Hey, I would just like to gather all your opinions on maybe transferring from Gitter to Discord. I find when using Gitter it is much harder to keep track of messages and get notified when they come. I think such a change would make it easier for people coming in to ask questions or give feature ideas and stuff because Gitter is not as organized.
Emmanuel Segun-Lean
@LeanKhan
@shadowtime2000 yeah Gitter is not the best. But I haven't used Discord before so why not. Github has this new Discussions feature for repos have you considered that?
shadowtime2000
@shadowtime2000
@LeanKhan Yeah I know about discussions. They are pretty useful, but they aren't as great for stuff like just really really small problems that people are having with their code that they need help with.
Rubin Bhandari
@rubiin
can we include markojs benchmarks as well
shadowtime2000
@shadowtime2000
@rubiin What do you mean? As in including them in the benchmark? I don't think MarkoJS really fits as a template engine because it is more of an isomorphic UI framework
Simon Layfield
@simonlayfield
Hi all - I was wondering if there is a way to catch and display eta template errors in the browser? Using Express, and not sure how to go about it. Any help would be greatly appreciated.
shadowtime2000
@shadowtime2000
@simonlayfield I think you could just use a try {} catch (e) {} to do that inside of the request handler
Simon Layfield
@simonlayfield
Oh, yeah I'll try that.
Andre Mas
@ajmas_gitlab
Currently looking at moving from ejs to eta, but not sure how to inject variables, such that I don't need to do it explicitly it in every res.render() call
Not seeing anything mentioned in the docs and also trying to deal with i18n-express translation block not being available: Error: {} translate is not defined
Andre Mas
@ajmas_gitlab
okay, turns out it is the same, just by default accessible via 'it'
Avery Fay
@btmorex
Hi, I'm trying to use eta in a webworker and webpack is pulling in the cjs version (even though my config works for other npm packages). Anyone have any ideas? I wrote the following stackoverflow question because I'm not sure where the fault lies: https://stackoverflow.com/questions/67560485/webpack-targeting-webworker-wont-import-browser-version-of-a-dependency