mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: speed up page load
This commit is contained in:
15 files changed
+80
-106
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import DOMServer from 'react-dom/server.browser';
|
||||
|
||||
export function substitute(str: string, obj: any) {
|
||||
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
|
||||
@@ -32,6 +34,7 @@ export function secureRandomString(digit = 32, dict = defaultDict) {
|
||||
type Substitution = string | number | { templateRaw: true, html: string };
|
||||
|
||||
export function tpl(pieces: TemplateStringsArray, ...substitutions: Substitution[]) {
|
||||
if (React.isValidElement(pieces)) return DOMServer.renderToStaticMarkup(pieces);
|
||||
let result = pieces[0];
|
||||
for (let i = 0; i < substitutions.length; ++i) {
|
||||
const subst = substitutions[i];
|
||||
|
||||
Reference in new issue
Block a user