Comments (7)
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.
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.
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.
@MartinX3 @SoftMachina Doesn't this work for you? korlibs-archive/korge-next@25d4520#diff-b77af0d60bc9f76c64298027e1d9b87e6c9ce56512f955c601c6a30f9d80058bR37
It seems to work properly already
from korte.
@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.
@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.
@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)
- Yaml issue
- YAML: Issue parsing map of lists
- Publish on Maven Central HOT 20
- Configurable escaping for non-HTML templates HOT 4
- Crash in Kotlin native when used from a different thread HOT 3
- Fails to access fields on Android
- Fix capture block HOT 1
- Accessing a property in a list of object not working on IOS HOT 1
- Decoding from string to serialized data class and accessing its properties on IOS causing segmentation fault HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from korte.