Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 17 07:36
    art049 edited #189
  • Sep 15 13:18
    art049 opened #189
  • Aug 23 22:45

    shadowtime2000 on master

    Update Benchmark modules > Upd… Merge pull request #188 from gi… (compare)

  • Aug 23 22:45
    shadowtime2000 closed #188
  • Aug 23 22:45
    shadowtime2000 commented #188
  • Aug 23 22:00
    gitBaiano commented #188
  • Aug 23 17:33
    paescuj commented #188
  • Aug 22 03:42
    shadowtime2000 assigned #181
  • Aug 22 03:42
    shadowtime2000 commented #181
  • Aug 21 19:44
    NightScript370 commented #181
  • Aug 14 13:15
    rubiin closed #169
  • Aug 11 20:40
    gitBaiano commented #188
  • Aug 11 06:43
    bacloud22 closed #184
  • Aug 11 06:43
    bacloud22 commented #184
  • Aug 11 06:42
    bacloud22 commented #184
  • Aug 11 02:05
    shadowtime2000 commented #180
  • Aug 11 01:56
    shadowtime2000 commented #184
  • Aug 04 19:31
    Javiani closed #186
  • Aug 04 19:31
    Javiani commented #186
  • Aug 04 08:47
    bacloud22 commented #184
shadowtime2000
@shadowtime2000
Yeah it most likely has something to do with how you render the data in the JS
Rubin Bhandari
@rubiin
i figured it out
shadowtime2000
@shadowtime2000
cool
Emmanuel Segun-Lean
@LeanKhan
<%~ E.includeFile("cart-component.vue") %>
I still wonder why this works ^
<cart-component :items="<%= items %>"></cart-component>
shadowtime2000
@shadowtime2000
I actually saw a stackoverflow for that but for EJS
the reason is that any file that is used will be used as if it was an Eta file
so basically it will just copy and paste it if there are no delimiters @LeanKhan
Orellabac
@orellabac
Hi. I few weeks ago I discovered eta I was very happy. It reminded my of ASPClassic and I decided to the a toy project where I could try it out. I had to create a plugin (probably not in the best way) and was able to reproduce most if this features. So if anybody else is interested please visit: https://github.com/orellabac/asp-classic-to-nodejs
Davorin Šego
@dsego
Hi folks,
What do you think about having a function/directive that does parallel async includes?
Like the following example, but without the boilerplate of doing Promise.all.
<%
const [AsyncComponent1, AsyncComponent2] = await Promise.all([
  includeFile('AsyncComponent.eta', { delay: 200 }),
  includeFile('AsyncComponent.eta', { delay: 300 })
])
%>
<h1>This should take ~300ms </h1>
<%~ AsyncComponent1 %>
<%~ AsyncComponent2 %>
I would like to just do this instead:
<h1>This should take ~300ms </h1>
<%~ defer('AsyncComponent.eta', { delay: 200 }) %>
<%~ defer( 'AsyncComponent.eta', { delay: 300 }) %>
I've been trying to make a plugin that does this, but can't make it work yet.
Damian
@damiantoczek
Hello, I come from EJS and I have a layout that has other layouts inside, how can I do this with Eta? For example my layout is called layout.eta, then i have a page called cpu-list.eta and the cpu-list has includes. But I don't know how to add the cpu-list into the layout. Because in EJS it's res.render('cpu-list', {layout: './layout.ejs'});
Damian
@damiantoczek
Ok I got it i need to use and add body: await eta.renderFile().
shadowtime2000
@shadowtime2000
@dsego What have you gotten so far? I think it should pretty simple, when you process the template you get everything defer usage and then add the statement at the top and replace the defer statements.
5 replies

Ok I got it i need to use and add body: await eta.renderFile().

@damiantoczek I am a little confused by what you mean by this, but you should check out the docs page on layouts

Davorin Šego
@dsego
What's the meaning behind t values being i, e and r ?
shadowtime2000
@shadowtime2000
@dsego i means simple interpolated values with <%= e means <% and r means <%~, I actually don't know the reasoning behind shortened names like this
Davorin Šego
@dsego
ah so e is probably eval and r could be raw.
Thanks!
shadowtime2000
@shadowtime2000
np
shadowtime2000
@shadowtime2000
Poll: How would you feel about more content being added to the Blog part of the docs site?
I noticed it doesn't really have much but adding some good template engine related content may be worth it to drive more people to Eta
Emmanuel Segun-Lean
@LeanKhan
@shadowtime2000 i didn't even know about the blog until now. Its a single post I'm seeing introducing Eta. Yeah, it could have articles that address some commom problems devs have with Nodejs template engines. With some good SEO, more people will know about it.
shadowtime2000
@shadowtime2000
Maybe I could write a post there like "What is an Embedded JS Template Engine?"
Emmanuel Segun-Lean
@LeanKhan
@shadowtime2000 hmm, i think the title is too long haha and not approachable. But yeah its a good start
What makes it 'embedded' actually?
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: