Text with interpolation

The complete source of structure_text.ek9, compiled by the EK9 compiler. Shown on structure.html.

#!ek9
defines module site.structure.text

  defines record

    Product
      name <- String()

      Product()
        -> productName as String
        name: productName

      default operator ?

  defines text for "en"
     
    //Define some text in English and wrap in a 'text' object.
    ProductsText
      productsTitle
        "Products"
      productFineDetails()
        "The fine details"
      share
        "Share"
      moreDetailsOn()
        -> product as Product
        `More details on ${product.name}`
        
  defines program
  
    TestText
      stdout <- Stdout()
      text <- ProductsText("en")
      
      specialProduct <- Product("Special")
      stdout.println(text.productsTitle())
      stdout.println(text.moreDetailsOn(specialProduct))

Download structure_text.ek9

Output

Products
More details on Special