Skip to content

Commit

Permalink
Make Qute doc more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Apr 15, 2024
1 parent ef0592b commit c80d8c5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
42 changes: 32 additions & 10 deletions docs/src/main/asciidoc/qute.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ Clone the Git repository: `git clone {quickstarts-clone-url}`, or download an {q

The solution is located in the `qute-quickstart` link:{quickstarts-tree-url}/qute-quickstart[directory].

[[hello-qute-web]]
== Hello World with Qute Web
[[serving-templates]]
== Serving Qute templates via http

If you want to serve your templates via http:

1. The Qute Web extension allows you to directly serve via http templates located in `src/main/resource/templates/pub/`. In that case you don't need any Java code to "plug" the template, for example, the template `src/main/resource/templates/pub/foo.html` will be served from the paths `/foo` and `/foo.html` by default.
2. For finer control, you can combine it with Quarkus REST or Quarkus RESTEasy to control how your template will be served. All files located in the `src/main/resources/templates` directory and its subdirectories are registered as templates and can be injected in a REST resource.

If you want to use Qute in your Quarkus Web application, add the Qute Web extension first:
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
.pom.xml
----
Expand All @@ -38,16 +42,19 @@ If you want to use Qute in your Quarkus Web application, add the Qute Web extens
<artifactId>quarkus-qute-web</artifactId>
</dependency>
----
+

[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
.build.gradle
----
implementation("io.quarkiverse.qute.web:quarkus-qute-web")
----

All files located in the `src/main/resources/templates` directory and its subdirectories are registered as templates. Templates are validated during startup and watched for changes in the development mode.
NOTE: The Qute Web extension is still using the quarkiverse group-id, it is part of the Quarkus platform (so it's is included in the bom), we are working on moving it to Quarkus Core.

[[hello-qute-web]]
=== Serving Hello World with Qute

Now, let's start with a Hello World html template:
Let's start with a Hello World template:

.src/main/resources/templates/pub/hello.html
[source]
Expand All @@ -60,14 +67,29 @@ NOTE: Templates located in the `pub` directory are served via HTTP. Automaticall

If your application is running, you can open your browser and hit: http://localhost:8080/hello?name=Martin

For more information about Qute Web, see the https://docs.quarkiverse.io/quarkus-qute-web/dev/index.html[Qute Web guide].
For more information about Qute Web options, see the https://docs.quarkiverse.io/quarkus-qute-web/dev/index.html[Qute Web guide].

[[hello-qute-rest]]
== Hello World with Jakarta REST
=== Hello Qute and REST

For finer control, you can combine Qute Web with Quarkus REST or Quarkus RESTEasy to control how your template will be served

If you want to use Qute in your Jakarta REST application, you still need to add the Qute Web extension first (see <<hello-qute-web>>) and make sure you have the Quarkus REST (formerly RESTEasy Reactive) extension.
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
.pom.xml
----
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
----

[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
.build.gradle
----
implementation("io.quarkus:quarkus-rest")
----

Here is a very simple text template:
A very simple text template:

.hello.txt
[source]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/web.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For templating and server-side rendering with Quarkus, there are different engin

Qute is designed specifically to meet the Quarkus needs, and help you deal with templates, snippets, and partials and render the data from your storage. It is inspired by the most famous template engines, it is fast, type-safe, works in native, and has a lot of nice features.

To install Qute Web, follow xref:qute.adoc[the instructions].
To install Qute Web, follow xref:qute.adoc#serving-templates[the instructions].

Here is a simple example of a Qute template:

Expand Down

0 comments on commit c80d8c5

Please sign in to comment.