Code generator.
This is a repository for operation confirmation.
There are many libraries that generate code using handlebars.js
and ejs
.
However, readability is low. It is not possible to directly test or confirm
operation.
Below is an example of Ract, but it is difficult to read because of the many tags. Syntax highlighting is also disabled.
It is difficult to produce because it is not possible to check directly.
import React from 'react'
type Props = {
}
export const <%= h.changeCase.pascal(name) %>: React.FC<Props> = ({}) => {
return (
<>
<h1><%= h.changeCase.pascal(name) %></h1>
</>
)
}
brew install f2
Create a file like this one.
./tpl/fruits/fruits.html
<p> This is red fruits </p>
<p> This is green fruits </p>
./generation.ts
import { generate } from "https://deno.land/x/shenron/mod.ts";
generate({
dir: {
output: "./output",
template: "./demo/tpl/fruits",
},
replacements: [{
before: "fruits",
after: "apple",
}, {
before: "Fruits",
after: "Apple",
}],
});
Execute.
deno run --allow-run --allow-read --allow-write --allow-env --allow-sys ./generation.ts
./output/apple/apple.html
<p> This is red apple </p>
<p> This is green apple </p>
Please use alphabetic letters for replacements
as much as possible.