Git Product home page Git Product logo

barber's Issues

Add a customized localized formatters for DocumentData Duration, Instant, Money types

For example, a DocumentData with a paramter of type Money could include a lambda on how to format that anytime it is rendered removing the need for every DocumentData constructor to format before construction.

data class RecipientReceipt(
  val sender: String,
  @BarberField(fomat = { amount ->
    Money.of(amount).asCasual()
  })
  val amount: Money,
  val cancelUrl: String,
  @BarberField(format = { dateTime -> Instant.of(dateTime).format("YYYY-MM-DD") })
  val deposit_expected_at: Instant
) : DocumentData

anyone knows how to render List data using Barber(0.3.3)?

like mustache demo:

Template:
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}

Input:
{
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
]
}

output:
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>

I used Set type, but there was a execption, like:
"Failure to generate signature because of [memberProperty=properties] which must be a data class [returnType=kotlin.collections.Set<com.microsoft.thrifty.ogen.IDLModelHeaderProperty>]"

Support null fields in DocumentTemplate

Documents can have null fields, DocumentData can have null fields, DocumentTemplates should support null fields as well.

Consider case of a DocumentTemplate that has the entire field as a DocumentData variable and targets Document with nullable fields. Currently I don't think this is possible because the DocumentData variable even if set to null, can't propagate through the DocumentTemplate on render correctly.

Open Questions

Hello devs!

We have around 6 Mio Users so we send a lot of emails daily.

We are currently investigating your library for our purposes and since it is relatively new I have some questions on which I yet couldn't find any answers online yet:

  • Does your templating engine support partials? It is a quite crutial feature for us. If yes how can I incorporate such a Template into another? A tutorial in the README would be nice.
  • Does your templating engine support loading of files instead of making dozens of Kotlin files (also with potentially partials?)
  • Your Locale does only support english, spanish and french. Why only these three? Does it make a difference at all when rendering?

Misspelling in the website

Hello, I spotted a typo on the main website page:

Could the same unique data blob could be used to support templates in different languages?

I couldn't send a PR because of #94

Have a great day!

Louis CAD

Add validation & tests for only supporting specific types in DocumentData

Especially once field stemming is supported, we want to explicitly indicate which types are supported and which aren't.

  @Disabled @Test
  fun `Fails on a non supported DocumentData unit`() {
    data class StrangeUnitDocumentData(
      val strange: Unit
    ) : DocumentData

    val strangeUnitEN_US = DocumentTemplate(
      fields = mapOf(
        "sms_body" to "That's {{ strange }}"
      ),
      source = StrangeUnitDocumentData::class,
      targets = setOf(TransactionalSmsDocument::class),
      locale = Locale.EN_US
    )

    val exception = assertFailsWith<BarberException> {
      BarbershopBuilder()
        .installDocument<TransactionalEmailDocument>()
        .installDocument<TransactionalSmsDocument>()
        .installDocumentTemplate<StrangeUnitDocumentData>(strangeUnitEN_US)
        .build()
    }
    assertEquals(
      """
        |Problems
        |1) ...
        |
      """.trimMargin(),
      exception.toString())
  }

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.