Skip to content

Commit

Permalink
bump version to 0.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
edadma committed Jun 2, 2018
1 parent e333384 commit 1a2c4fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 36 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Backslash
[![Build Status](https://www.travis-ci.org/edadma/backslash.svg?branch=master)](https://www.travis-ci.org/edadma/backslash)
[![Coverage Status](https://coveralls.io/repos/github/edadma/backslash/badge.svg?branch=master)](https://coveralls.io/github/edadma/backslash?branch=master)
[![License](https://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/edadma/backslash/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/latest_release-v0.4.3-orange.svg)](https://github.com/edadma/backslash/releases/tag/v0.4.3)
[![Version](https://img.shields.io/badge/latest_release-v0.4.4-orange.svg)](https://github.com/edadma/backslash/releases/tag/v0.4.4)

*Backslash* is a string templating language written in [Scala](http://scala-lang.org). Backslash looks like [TeX](https://en.wikipedia.org/wiki/TeX) with the default delimiters (which can be changed), but it's not TeX. Backslash behaves like any other macro/templating language: it copies input text to output. Backslash is an attempt to create a dryer templating language that still allows you to copy HTML (or whatever you're using it for) verbatim. So, although Backslash is somewhat inspired by TeX, it shares very little in common with it except less typing. If your HTML doesn't containing any scripting then the "TeXish" delimiters (`\`, `{`, `}`) are usually fine. However, as in [Mustache](http://mustache.github.io/), delimiters can be changed anywhere in the input stream (except between command arguments).

Expand Down Expand Up @@ -156,7 +156,7 @@ This program prints
This next example shows how to use *Backslash* as an executable from the command line.

```bash
echo "testing \join \v \", \"" | java -jar backslash-0.4.3.jar -j "{v: [\"one\", \"two\", \"three\"]}" --
echo "testing \join \v \", \"" | java -jar backslash-0.4.4.jar -j "{v: [\"one\", \"two\", \"three\"]}" --
```

The above command prints
Expand All @@ -180,7 +180,7 @@ Use the following definition to use Backslash in your Maven project:
<dependency>
<groupId>xyz.hyperreal</groupId>
<artifactId>backslash</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>
</dependency>
```

Expand All @@ -189,14 +189,14 @@ Add the following to your `build.sbt` file to use Backslash in your SBT project:
```sbt
resolvers += "Hyperreal Repository" at "https://dl.bintray.com/edadma/maven"

libraryDependencies += "xyz.hyperreal" %% "backslash" % "0.4.3"
libraryDependencies += "xyz.hyperreal" %% "backslash" % "0.4.4"
```

### Executable

An executable can be downloaded from [here](https://dl.bintray.com/edadma/generic/backslash-0.4.3.jar). *You do not need* the Scala library for it to work because the JAR already contains all dependencies. You just need Java 8+ installed.
An executable can be downloaded from [here](https://dl.bintray.com/edadma/generic/backslash-0.4.4.jar). *You do not need* the Scala library for it to work because the JAR already contains all dependencies. You just need Java 8+ installed.

Run it as a normal Java executable JAR with the command `java -jar backslash-0.4.3.jar <template>` in the folder where you downloaded the file, where *template* is the name of the template file to be rendered.
Run it as a normal Java executable JAR with the command `java -jar backslash-0.4.4.jar <template>` in the folder where you downloaded the file, where *template* is the name of the template file to be rendered.

Building
--------
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "backslash"

version := "0.4.3"
version := "0.4.4"

scalaVersion := "2.12.6"

Expand Down
2 changes: 1 addition & 1 deletion docs/regular-command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ Takes a string and a date (`java.time.temporal.TemporalAccessor`).

### Output

Formats the second argument according to the pattern given by the first (see [Date Format Patterns](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns)).
The second argument formatted according to the pattern given by the first (see [Date Format Patterns](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns)).

### Example

Expand Down
37 changes: 11 additions & 26 deletions src/main/scala/Command.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ object Command {
new Command( "default", 2 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any =
renderer eval args match {
case List( a: Any, b: Any ) =>
if (b == nil)
a
else
b
case List( a: Any, b: Any ) => if (b == nil) a else b
}
},

Expand All @@ -229,8 +225,8 @@ object Command {
new Command( "drop", 2 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any =
renderer.eval( args ) match {
case List( n: BigDecimal, s: Seq[_] ) => s drop n.toInt
case List( a, b ) => problem( pos, s"expected arguments <number> <sequence>, given $a, $b" )
case List( n: BigDecimal, s: Seq[_] ) if n.isValidInt => s drop n.toInt
case List( a, b ) => problem( pos, s"expected arguments <integer> <sequence>, given $a, $b" )
}
},

Expand Down Expand Up @@ -318,14 +314,6 @@ object Command {
}
},

new Command( "join", 2 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any =
renderer.eval( args ) match {
case List( s: Seq[_], sep: String ) => s mkString sep
case List( a, b ) => problem( pos, s"expected arguments <sequence> <separator>, given $a, $b" )
}
},

new Command( "last", 1 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any =
renderer.eval( args ) match {
Expand Down Expand Up @@ -371,7 +359,7 @@ object Command {
"\n"
},

new Command( "neg", 1 ) {
new Command( "negate", 1 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any = {
renderer.eval( args.head ) match {
case n: BigDecimal => -n
Expand Down Expand Up @@ -411,7 +399,8 @@ object Command {
case None => problem( pos, s"not a number: $s" )
case Some( n ) => n
}
case List( a ) => problem( pos, s"expected string argument, given $a" )
case List( n: BigDecimal ) => n
case List( a ) => problem( pos, s"expected a string or number argument, given $a" )
}
},

Expand Down Expand Up @@ -494,8 +483,8 @@ object Command {
new Command( "slice", 3 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any = {
renderer.eval( args ) match {
case List( s: String, start: BigDecimal, end: BigDecimal ) if start.isWhole && end.isWhole => s.slice( start.intValue, end.intValue )
case List( s: Seq[_], start: BigDecimal, end: BigDecimal ) if start.isWhole && end.isWhole => s.slice( start.intValue, end.intValue )
case List( s: String, start: BigDecimal, end: BigDecimal ) if start.isValidInt && end.isValidInt => s.slice( start.intValue, end.intValue )
case List( s: Seq[_], start: BigDecimal, end: BigDecimal ) if start.isValidInt && end.isValidInt => s.slice( start.intValue, end.intValue )
case List( a, b ) => problem( pos, s"expected arguments <string> <start> <end> or <sequence> <start> <end>: $a, $b" )
}
}
Expand All @@ -506,11 +495,7 @@ object Command {
val on = optional get "on" map (_.toString)
val desc = (optional get "order" map (_.toString)) contains "desc"

def comp( a: Any, b: Any ) =
if (desc)
!lt( a, b )
else
lt( a, b )
def comp( a: Any, b: Any ) = if (desc) !lt( a, b ) else lt( a, b )

def lt( a: Any, b: Any ) =
(a, b) match {
Expand Down Expand Up @@ -561,8 +546,8 @@ object Command {
new Command( "take", 2 ) {
def apply( pos: Position, renderer: Renderer, args: List[AST], optional: Map[String, Any], context: AnyRef ): Any =
renderer.eval( args ) match {
case List( n: BigDecimal, s: Seq[_] ) => s take n.toInt
case List( a, b ) => problem( pos, s"expected arguments <number> <sequence>, given $a, $b" )
case List( n: BigDecimal, s: Seq[_] ) if n.isValidInt => s take n.toInt
case List( a, b ) => problem( pos, s"expected arguments <integer> <sequence>, given $a, $b" )
}
},

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ object Main extends App {

def usage {
"""
|Backslash v0.4.3
|Backslash v0.4.4
|
|Usage: java -jar backslash-0.4.3.jar <options> <template>
|Usage: java -jar backslash-0.4.4.jar <options> <template>
|
|Options: --help display this help and exit
| -s <name> <string> assign <string> to variable <name>
Expand Down

0 comments on commit 1a2c4fd

Please sign in to comment.