simon639 / format-string

Simple template strings for common lisp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

format-string

Build Status Coverage Status

Templated strings for common lisp.

(let ((name "format-string")
      (use "templated strings")
      (how-many "as many as you want"))

  #`${name} is a package implementing ${use} as a reader macro.
You can insert one, two, or ${how-many} variables into a string so that it's
arguably more readable than a format string in some circumstances.`)

; => "format-string is a package implementing templated strings as a reader macro.
; You can insert one, two, or as many as you want variables into a string so that it's
; arguably more readable than a format string in some circumstances."

Using in your project

Probably the sanest way is to use named readtables, like so:

(named-readtables:in-readtable format-string:syntax)

(defvar potato-type "yukon")

(defvar exclamation #`I love ${potato-type} potatoes!`)

But you can also bind the function to a macro dispatcher

(set-dispatch-macro-character #\# #\` #'format-string:parse-format-string)

About

Simple template strings for common lisp

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Common Lisp 100.0%