Git Product home page Git Product logo

Comments (7)

soywiz avatar soywiz commented on September 24, 2024 1

Inside the template, you can use the set tag to create aliases, or set local variables for complex expressions:
https://docs.korge.org/korte/tags/#set

Also you can precompute endDate in kotlin code and pass it to the template.
If you need specific property names for your DTOs my suggestion is to create a separate layer of DTOs and transform your input to those DTOs so you only expose what you want and with the naming you want. Note that Kotlin extension members are not available in korte templates.

from korte.

soywiz avatar soywiz commented on September 24, 2024

Hey @SoftMachina I guess I need more context to understand this. Can you put a sample of Kotlin code and template code showing what you would to do?

from korte.

MartinX3 avatar MartinX3 commented on September 24, 2024

Hey @soywiz
We want to render a table.
The datasource contains a startdate (localdate) and a duration in days (integer).
On this table we want to filter/remove every entry in the past or in the future.

As example

  • past entry: if the enddate (startdate + duration days) is in the past.
  • future entry: if the startdate is in the future.

Or that we can order the entries with the locadate + duration integer entries.

from korte.

soywiz avatar soywiz commented on September 24, 2024

@MartinX3 @SoftMachina Doesn't this work for you? korlibs-archive/korge-next@25d4520#diff-b77af0d60bc9f76c64298027e1d9b87e6c9ce56512f955c601c6a30f9d80058bR37
It seems to work properly already

from korte.

MartinX3 avatar MartinX3 commented on September 24, 2024

@soywiz Thank you for your example
In our case the enduser just writes an email template in our frontend.
Is it possible to assign the individual variable names for startdate and duration in the template text or do we need to rename the database variable names to standard ones?
The enduser doesn't touch kotlin code. He has just a text field.

from korte.

SoftMachina avatar SoftMachina commented on September 24, 2024

@soywiz my question may has been a little to vague, I'm sorry for that. What I'm trying to do is, writing a custom filter to filter out dates in a table that are < today. For that, I use something like [startingDate, duration] | onlyFuture in the template. In the Kotlin backend, I then proceed to use the subject in the context of the filter, to get my hands on both these values. My initial issue was that I have to convert the startingDate from String to LocalDate myself, which I would much rather prefer to be an extension of the Dynamic2 thing you wrote. That way, the hassle of conversion could be avoided.

from korte.

soywiz avatar soywiz commented on September 24, 2024

@SoftMachina Dynamic2 is in the Kotlin/Common sourceSet. Kotlin Common doesn't have dates yet in the standard library, so it would be a bit problematic handling dates there because of that

from korte.

Related Issues (10)

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.