Rename cmp to scope
This commit is contained in:
parent
b771eec3b5
commit
92c11d61a9
5 changed files with 13 additions and 13 deletions
src
|
@ -11,7 +11,7 @@
|
|||
|
||||
(pi:define-element page ()
|
||||
(pi:h
|
||||
(section :data-cmp "pages/about"
|
||||
(section :data-scope "pages/about"
|
||||
(h1 "About")
|
||||
(a :href "/" :hx-boost "true"
|
||||
"top"))))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
(pi:define-element page ()
|
||||
(pi:h
|
||||
(section :data-cmp "pages/index"
|
||||
(section :data-scope "pages/index"
|
||||
(h1 "Hello, World!")
|
||||
(a :href "/about" :hx-boost "true"
|
||||
"About"))))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@scope ([data-cmp='pages/about']) {
|
||||
@scope ([data-scope='pages/about']) {
|
||||
:scope {
|
||||
height: 100svh;
|
||||
background-color: thistle;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@scope ([data-cmp='pages/index']) {
|
||||
@scope ([data-scope='pages/index']) {
|
||||
:scope {
|
||||
height: 100svh;
|
||||
background-color: aliceblue;
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
(:export #:collect-style-links))
|
||||
(in-package #:hp/view/optimizer)
|
||||
|
||||
(defun detect-components (page-str)
|
||||
(remove-duplicates (re:all-matches-as-strings "(?<=data-cmp=\")[^\"]*(?=\")"
|
||||
page-str)
|
||||
(defun detect-scopes (html-str)
|
||||
(remove-duplicates (re:all-matches-as-strings "(?<=data-scope=\")[^\"]*(?=\")"
|
||||
html-str)
|
||||
:test #'string=))
|
||||
|
||||
(defun components->stylesheets (data-cmps)
|
||||
(mapcar (lambda (cmp-name)
|
||||
(concatenate 'string "/styles/" cmp-name ".css"))
|
||||
data-cmps))
|
||||
(defun scopes->stylesheets (scopes)
|
||||
(mapcar (lambda (scope)
|
||||
(concatenate 'string "/styles/" scope ".css"))
|
||||
scopes))
|
||||
|
||||
(defun collect-style-links (page-str)
|
||||
(components->stylesheets (detect-components page-str)))
|
||||
(defun collect-style-links (html-str)
|
||||
(scopes->stylesheets (detect-scopes html-str)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue