mirror of
https://github.com/tonsky/rum.git
synced 2025-08-03 18:13:19 +08:00
Added rum/render-static-markup
This commit is contained in:
@ -141,7 +141,7 @@ Since 0.7.0, Rum supports pure-Clojure server-side rendering. In your clj/cljc f
|
||||
|
||||
Rum server-side rendering does not use React or Sablono, it runs completely in JVM with no overhead/complications of JavaScript.
|
||||
|
||||
Yes, you can use Rum for classical server-side rendering where you normally would use Hiccup or something similar. As of `[rum "0.8.0"]` and `[hiccup "1.0.5"]`, Rum is 2-3× times faster than Hiccup.
|
||||
Yes, you can use Rum for classical server-side rendering where you normally would use Hiccup or something similar. As of `[rum "0.8.0"]` and `[hiccup "1.0.5"]`, Rum is 2-3× times faster than Hiccup. Use `rum/render-static-markup` if you’re not planning to connect your page with React later.
|
||||
|
||||
Server-side components do not have full lifecycle support, but `:init`, `:will-mount` and `:did-mount` from mixins would be called at the component construction time.
|
||||
|
||||
@ -357,9 +357,14 @@ This is a detailed breakdown of what happens inside of Rum. By using `rum/defc`,
|
||||
|
||||
## Changes
|
||||
|
||||
### 0.8.3
|
||||
|
||||
- `rum/render-static-markup` call for pure HTML templating. Use it if you’re not planning to connect your page with React later
|
||||
- `rum/def*` macros now correctly retain metadata that already exists on a symbol (thx [aJchemist](https://github.com/aJchemist), PR #62)
|
||||
|
||||
### 0.8.2
|
||||
|
||||
- Add `rum.core/unmount` function (thx [emnh ](https://github.com/emnh), issue #61)
|
||||
- Add `rum.core/unmount` function (thx [emnh](https://github.com/emnh), issue #61)
|
||||
|
||||
### 0.8.1
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
||||
:let [path (str "perf/pages/" page)]]
|
||||
(let [comp (convert-page path)]
|
||||
(println "\n--- Testing" page (str "(" (file-size path) ")") "---")
|
||||
(criterium/quick-bench (rum/render-html comp)))
|
||||
(criterium/quick-bench (rum/render-static-markup comp)))
|
||||
|
||||
(let [comp (binding [*convert-style?* false]
|
||||
(convert-page path))]
|
||||
|
@ -101,6 +101,7 @@
|
||||
;;; Server-side rendering support
|
||||
|
||||
(def render-html render/render-html)
|
||||
(def render-static-markup render/render-static-markup)
|
||||
|
||||
(def build-class server/build-class)
|
||||
(def args->state server/args->state)
|
||||
|
@ -259,11 +259,12 @@
|
||||
|
||||
(render-classes! classes sb)
|
||||
|
||||
(when (== @*key 1)
|
||||
(append! sb " data-reactroot=\"\""))
|
||||
|
||||
(append! sb " data-reactid=\"" @*key "\"")
|
||||
(vswap! *key inc)
|
||||
(when *key
|
||||
(when (== @*key 1)
|
||||
(append! sb " data-reactroot=\"\""))
|
||||
|
||||
(append! sb " data-reactid=\"" @*key "\"")
|
||||
(vswap! *key inc))
|
||||
|
||||
(render-content! tag attrs children *key sb)))
|
||||
|
||||
@ -284,7 +285,8 @@
|
||||
|
||||
String
|
||||
(-render-html [this parent *key sb]
|
||||
(if (> (count parent) 1)
|
||||
(if (and *key
|
||||
(> (count parent) 1))
|
||||
(let [key @*key]
|
||||
(vswap! *key inc)
|
||||
(append! sb "<!-- react-text: " key " -->" (escape-html this) "<!-- /react-text -->"))
|
||||
@ -340,3 +342,9 @@
|
||||
(-render-html src nil (volatile! 1) sb)
|
||||
(.insert sb (.indexOf sb ">") (str " data-react-checksum=\"" (adler32 sb) "\""))
|
||||
(str sb))))
|
||||
|
||||
|
||||
(defn render-static-markup [src]
|
||||
(let [sb (StringBuilder.)]
|
||||
(-render-html src nil nil sb)
|
||||
(str sb)))
|
||||
|
Reference in New Issue
Block a user