Giter Club home page Giter Club logo

safe-string-interpolation's Introduction

Typesafe Interpolation

Build Status Gitter Maven Central

An insanely simple type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs, and for safe string operations !

@ import $ivy.`io.github.afsalthaj::safe-string-interpolation:2.1.3`
import $ivy.$

@ import com.thaj.safe.string.interpolator._
import com.thaj.safe.string.interpolator._

@ case class Port(int: Int) extends AnyVal
defined class Port

@ val port = Port(1)
port: Port = Port(1)

@ ss"Db details: Port is ${port}"
cmd7.sc:1: could not find implicit value for parameter ev: com.thaj.safe.string.interpolator.Safe[ammonite.$sess.cmd5.Port]
val res7 = ss"Db details: Port is ${port}"
           ^
Compilation Failed

@ ss"Db details: Port is ${port.int}"
res7: SafeString = SafeString("Db details: Port is 1")

// Another example
@ case class Prefix(value: String) 
defined class Prefix

@ case class BucketName(value: String) 
defined class BucketName

@ val prefix = Prefix("foo") 
prefix: Prefix = Prefix("foo")

@ val bucketName = BucketName("6666-bucket") 
bucketName: BucketName = BucketName("6666-bucket")

@ val path = s"${bucketName}/${prefix}" 
path: String = "BucketName(6666-bucket)/Prefix(foo)"

@ val path = ss"${bucketName}/${prefix}" 
cmd7.sc:1: could not find implicit value for parameter ev: com.thaj.safe.string.interpolator.Safe[ammonite.$sess.cmd2.BucketName]
val path = ss"${bucketName}/${prefix}"
           ^
Compilation Failed


// Autoderivation module
@ import instances._
import instances._

@ ss"Db details: Port is ${port}"
res9: SafeString = SafeString("Db details: Port is { int : 1 }")

Checkout the project website for more features and possibilities.

safe-string-interpolation's People

Contributors

afsalthaj avatar guizmaii avatar michaelt293 avatar scala-steward avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

safe-string-interpolation's Issues

Clean up documentation examples

There should be more easily understandable examples in docs.

For publishing docs, it is as easy as
sbt docs/updateDoc. updateDoc will make sure the libraryDependencies part of the doc is updated with the latest version

Make doc publish part of travis

As of now the way to publish doc can be done only by the maintainer which is me.
For publishing docs, it is sbt docs/updateDoc. updateDoc will make sure the libraryDependencies part of the doc is updated with the latest version.

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.