Comments (3)
Thanks @volgin your feedback is important.
Unfortunately I am overwhelmed and planning to enhance documentation for more than on year. But I did not have time yet.
I have a lot of information spread on different articles, issues, README, wiki...
I will reopen this Issue to remember that I should include some patterns and idioms in HtmlFlow documentation.
BTW this paper https://gamboa.pt/img/my-papers/lnbip2020-unopinionated-templates.pdf put side by side some templating idioms between Thymeleaf and HtmlFlow. Maybe it could give a help in other issues.
from htmlflow.
Certainly you can. HtmlFlow is unopinionated and provides you several ways of doing it. Btw you can do it both in Dynamic and Static HTML.
You may find many examples of different kinds of use in Pet Clinic sample application in org/springframework/samples/petclinic/views
folder here: https://github.com/xmlet/spring-petclinic/tree/master/src/main/java/org/springframework/samples/petclinic/views
For instance, in CreateOrUpdateOwnerForm.java
you have a submit button , which contains the label Add Owner
or Update Owner
depending on whether the view is returned from the /owners/new
or /owners/ownerId/edit
path. To that end, you may find the following snippet in line 33:
.button().attrClass("btn btn-default").attrType(EnumTypeButtonType.SUBMIT)
.dynamic(bt -> {
if(owner == null) bt.text("Add Owner");
else bt.text("Update Owner");
})
.__() //button
Simply put, dynamic(elem -> ...)
or of(elem -> ...)
let you chain any control flow logic with the last created element passed to the lambda. In the previous example the element it is the button bt
.
The main difference between of()
and dynamic()
is that the former will keep the resulting HTML in cache and only evaluates the condition on first resolution/rendering. Whenever your condition depends of dynamic data, like a data model, then you should use dynamic()
.
I hope it helps.
from htmlflow.
This should be added to the documentation. I had to look through many issues before I found this answer.
from htmlflow.
Related Issues (20)
- Misunderstanding of how to use printStream to stream html HOT 4
- Add a couple of use cases from the upcoming paper showing the corresponding Thymeleaf dialect with HtmlFlow HOT 1
- Nesting dynamic bloc HOT 3
- Add documentation for the api HOT 5
- Documentation enhancement
- parametrized caching for dynamic blocks HOT 6
- Support single quoting for attributes (on element basis) HOT 5
- Enhancement: When parent template is initialized with a PrintStream, any internal use of addPartial should use implicitly that PrintStream so we avoid having to pass the PrintStream through the model parameter HOT 10
- Make newby() return structureless ElementVisitor HOT 1
- Flowifier improvement with JavaPoet
- Flowifier: Remove workaround to suppress useless emit of: `.text("\n")`
- How to create a custom tag/element? HOT 10
- View in inconsistent state when Dynamic block throws an exception!!! HOT 5
- Gradle build warnings... HOT 5
- Groovy compilation errors ... HOT 4
- Security Scan Warning - JSOUP...? HOT 1
- Input attribute checked=false|true not compliant HOT 3
- Cannot have full dynamic page HOT 1
- Is there any idea code folding plugin recommendation? HOT 3
- slf4j-simple should not be declared as a dependecy HOT 2
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 htmlflow.