Skip to content

Commit

Permalink
Add uppercase (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilps authored May 10, 2022
1 parent 3cd0c93 commit 16a03f4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM gcr.io/distroless/java17@sha256:51312565c020a77583a9c699eb4d92b99d9629f4109a333d49a7c4f7ed5f9f82

WORKDIR /app
COPY build/libs/pdfgen-1.4.6-all.jar app.jar
COPY build/libs/pdfgen-1.5.0-all.jar app.jar
COPY fonts fonts
COPY templates templates
COPY resources resources
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ mkdir {templates,data}/your_teamname # your_teamname can be anything, but it'll

[navikt/flex-sykepengesoknad-pdfgen](https://github.com/navikt/flex-sykepengesoknad-pdfgen) is a good example of how such a project can be set up.

### Helpers
[navikt/pdfgen/blob/master/src/main/kotlin/no/nav/pdfgen/template/Helpers.kt](https://github.com/navikt/pdfgen/blob/master/src/main/kotlin/no/nav/pdfgen/template/Helpers.kt) contains a collection of customs Helpers which implements functionality that is not part of the Handlebars language itself.

## Developing pdfgen

### Build and run tests
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "no.nav.pdfgen"
version = "1.4.6"
version = "1.5.0"

val handlebarsVersion = "4.3.0"
val jacksonVersion = "2.13.2"
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/no/nav/pdfgen/template/Helpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ fun registerNavHelpers(handlebars: Handlebars, env: Environment) {
}
)

registerHelper(
"uppercase",
Helper<String> { context, _ ->
context?.uppercase() ?: ""
}
)

registerHelper(
"inc",
Helper<Int> { context, _ ->
Expand Down
16 changes: 16 additions & 0 deletions src/test/kotlin/no/nav/pdfgen/HelperSpek.kt
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,22 @@ object HelperSpek : Spek({
}
}

describe("uppercase") {
val context = jsonContext(jsonNodeFactory.objectNode())

it("should uppercase all letters") {
handlebars.compileInline("{{uppercase \"brage bruker olsen\"}}").apply(context) shouldBeEqualTo "BRAGE BRUKER OLSEN"
}

it("should uppercase all lower letters") {
handlebars.compileInline("{{uppercase \"Brage Bruker Olsen\"}}").apply(context) shouldBeEqualTo "BRAGE BRUKER OLSEN"
}

it("should uppercase strings with numbers") {
handlebars.compileInline("{{uppercase \"0553 Oslo\"}}").apply(context) shouldBeEqualTo "0553 OSLO"
}
}

describe("breaklines") {
val context = jsonContext(jsonNodeFactory.objectNode())

Expand Down

0 comments on commit 16a03f4

Please sign in to comment.