Git Product home page Git Product logo

slisp's Introduction

Slisp

Slisp is an experimental string templating library for Godot written (at the moment) in GDScript. The current code is proof of concept and likely to change but should work if anyone would like to try it out.

Slisp is currently unoptised and designed for playing around with text adventures. I wouldn't reccomend it for high performance use. If it gets traction I might port it to C gode via GDNative.

Slisp supports

  • Templating strings with variables
  • Conditional logic (if and when)
  • Simple equality testing
  • Preserving whitespace

Installation

Download the slisp.gd file and drop it into addons/slisp (or where ever your like) in your Godot project.

Syntax

Slisp works by adding s-expressions to a string using < and >. Whitespace outside of expressions is preserved.

This is an example slisp template.

<put foo> is the value of foo

<when hello "world"> will print world when hello is truthy

<if bar "zap" "pow"> will print zap if bar is true,
otherwise it will print "pow".

<when this <str "t" "h" "a" "t">> you can next expressions,
this will print "that" when this is true

Usage

var Slisp = ResourceLoader.load("res://addons/slisp.gd")

var template = Slisp.new('Ya<when super_pirate "aaaaaa">r')

var state = { 'super_pirate': true }

var result = template.render(state) # use this in a text node or something

TODO list

  • Better error handling
  • Ability to escape characters with \
  • Debug/profiling mode
  • Ability to customise expression start and end tokens
  • Ability to distinguish between function names and variables (e.g. prefix one or the other with $ to avoid name collisions)
  • Turn this repo into a valid Godot project
  • Install slisp plus a 'playground' via an addon

slisp's People

Contributors

gtrogers avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

boyquotes

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.