Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update template to use {{replace-me}} instead of {replace-me}.

  • Loading branch information...
commit 32de3ff21bfb159db1d5817d4d3c69c68ce37f4a 1 parent f688112
@rejeep rejeep authored
View
15 ecukes-template.el
@@ -18,14 +18,13 @@
(defun ecukes-template-substitute (string substitutions)
"Substitute all SUBSTITUTIONS in STRING."
- (let ((result string))
- (mapc
- (lambda (substitution)
- (let ((old (car substitution))
- (new (cdr substitution)))
- (setq result (replace-regexp-in-string (format "{%s}" old) new result t))))
- substitutions)
- result))
+ (-each
+ substitutions
+ (lambda (substitution)
+ (let ((old (car substitution))
+ (new (cdr substitution)))
+ (setq string (s-replace (format "{{%s}}" old) new string)))))
+ string)
(defun ecukes-template-write (write-to template &optional substitutions)
"Write TEMPLATE to WRITE-TO with SUBSTITUTIONS."
View
12 templates/env.tpl
@@ -8,14 +8,14 @@
(project-directory
(file-name-directory
(directory-file-name features-directory))))
- (setq {project-name}-root-path project-directory)
- (setq {project-name}-util-path (expand-file-name "util" {project-name}-root-path)))
+ (setq {{project-name}}-root-path project-directory)
+ (setq {{project-name}}-util-path (expand-file-name "util" {{project-name}}-root-path)))
-(add-to-list 'load-path {project-name}-root-path)
-(add-to-list 'load-path (expand-file-name "espuds" {project-name}-util-path))
-(add-to-list 'load-path (expand-file-name "ert" {project-name}-util-path))
+(add-to-list 'load-path {{project-name}}-root-path)
+(add-to-list 'load-path (expand-file-name "espuds" {{project-name}}-util-path))
+(add-to-list 'load-path (expand-file-name "ert" {{project-name}}-util-path))
-(require '{project-name})
+(require '{{project-name}})
(require 'espuds)
(require 'ert)
View
4 templates/step.tpl
@@ -1,4 +1,4 @@
-({fn} "^{regex}$"
- (lambda ({args})
+({{fn}} "^{{regex}}$"
+ (lambda ({{args}})
))
View
6 test/ecukes-template-test.el
@@ -3,7 +3,7 @@
(should
(equal
(ecukes-template-substitute
- "replace {foo} in string"
+ "replace {{foo}} in string"
'(("foo" . "bar")))
"replace bar in string")))
@@ -12,7 +12,7 @@
(should
(equal
(ecukes-template-substitute
- "replace {foo} and {baz} in string"
+ "replace {{foo}} and {{baz}} in string"
'(("foo" . "bar")
("baz" . "qux")))
"replace bar and qux in string")))
@@ -23,5 +23,5 @@
(equal
(ecukes-template-substitute
"do not replace anything"
- '(("foo" . "bar")))
+ '(("not" . "NOT")))
"do not replace anything")))
Please sign in to comment.
Something went wrong with that request. Please try again.