Artemy d477de027a feat: middlewares
feat: highlighter
2024-05-15 16:09:01 +03:00

34 lines
844 B
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-namespace */
export namespace JSX {
export type Element = string;
export interface IntrinsicElements {
[elemName: string]: any;
}
}
export function createElement(
name: any,
props: { [id: string]: any },
...inner: (string | string[])[]
) {
const content = inner.flat().join('');
if (typeof name === 'string') {
props = props || {};
const propsstr = Object.keys(props)
.map((key) => {
const value = props[key];
if (key === 'className') return `class=${value}`;
else return `${key}=${value}`;
})
.join(' ');
return `<${name} ${propsstr}>${content}</${name}>`;
} else if (typeof name === 'function') {
return name(props, content);
} else {
return content;
}
}