aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-11 16:47:44 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-11 16:47:44 +0100
commit53665daee7a1fc1717c6c6dba0564e0efef25c93 (patch)
treea99ce35d720ce54bbd7c53f602649a15f51514b2 /guix-data-service/web
parentf2e123b7ac7363dcb9a1ea29b89606d6492870c9 (diff)
downloaddata-service-53665daee7a1fc1717c6c6dba0564e0efef25c93.tar
data-service-53665daee7a1fc1717c6c6dba0564e0efef25c93.tar.gz
Add some word handling utilities
These are useful for constructing HTML ids and similar things.
Diffstat (limited to 'guix-data-service/web')
-rw-r--r--guix-data-service/web/util.scm15
1 files changed, 14 insertions, 1 deletions
diff --git a/guix-data-service/web/util.scm b/guix-data-service/web/util.scm
index 44fae8a..574b29b 100644
--- a/guix-data-service/web/util.scm
+++ b/guix-data-service/web/util.scm
@@ -24,7 +24,10 @@
#:use-module (web uri)
#:export (request-path-components
file-extension
- directory?))
+ directory?
+
+ hyphenate-words
+ underscore-join-words))
(define (request-path-components request)
(split-and-decode-uri-path (uri-path (request-uri request))))
@@ -34,3 +37,13 @@
(define (directory? filename)
(string=? filename (dirname filename)))
+
+(define (hyphenate-words words)
+ (string-join
+ (string-split words #\space)
+ "-"))
+
+(define (underscore-join-words words)
+ (string-join
+ (string-split words #\space)
+ "_"))