forked from nicojs/typed-html
-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add pug to benchmarks #352
Open
cjhw
wants to merge
1
commit into
kitajs:master
Choose a base branch
from
cjhw:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import pug from 'pug'; | ||
|
||
const templates = { | ||
purchase: pug.compile(` | ||
.purchase.purchase-card | ||
.purchase-name= name | ||
.purchase-price= price | ||
.purchase-quantity= quantity | ||
`), | ||
|
||
layout: pug.compile(` | ||
doctype html | ||
html(lang="en") | ||
head | ||
!= head | ||
body | ||
!= children | ||
`), | ||
|
||
head: pug.compile(` | ||
div | ||
title= title | ||
meta(name="description" content="A description") | ||
meta(name="keywords" content="some, keywords") | ||
meta(name="author" content="Some Author") | ||
meta(name="viewport" content="width=device-width, initial-scale=1.0") | ||
link(rel="stylesheet" href="styles.css") | ||
script(src="script.js") | ||
meta(name="twitter:card" content="summary") | ||
meta(name="twitter:site" content="@site") | ||
meta(name="twitter:title" content="Title") | ||
meta(name="twitter:description" content="A description") | ||
meta(name="twitter:creator" content="@creator") | ||
meta(name="twitter:image" content="image.jpg") | ||
meta(content="Title") | ||
meta(content="website") | ||
script(src="https://cdn.jsdelivr.net/npm/axios-cache-interceptor@1/dev/index.bundle.js") | ||
script(src="https://cdn.jsdelivr.net/npm/axios-cache-interceptor@1/dist/index.bundle.js") | ||
`), | ||
|
||
main: pug.compile(` | ||
main.main | ||
header.header | ||
h1.header-title Hello #{name} | ||
nav.header-nav | ||
ul.header-ul | ||
li.header-item | ||
a(href="/") Home | ||
li | ||
a(href="/about") About | ||
!= children | ||
`), | ||
|
||
userProfile: pug.compile(` | ||
section.user-profile | ||
h2.user-profile.title User Profile: #{name} | ||
p.user-profile.info Email: [email protected] | ||
p.user-profile.info Address: 123 Main St, City, Country | ||
p.user-profile.info Phone: 123-456-7890 | ||
`), | ||
|
||
sidebar: pug.compile(` | ||
aside.sidebar | ||
h2.purchase.title Recent Purchases | ||
ul.purchase.list | ||
li.purchase-preview Purchase number 1 - $0.00 | ||
`), | ||
|
||
pageContent: pug.compile(` | ||
.page-content | ||
h2.title.mb-4.h2 Welcome to our store | ||
p.p.text.mb-0 | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis magna | ||
| id dolor ultricies, eget pretium ligula sodales. Cras sit amet turpis nec | ||
| lacus blandit placerat. Sed vestibulum est sit amet enim ultrices rutrum. | ||
| Vivamus in nulla vel nunc interdum vehicula. | ||
p.p.text.mb-0 | ||
| Pellentesque efficitur tellus id velit vehicula laoreet. Proin et neque ac | ||
| dolor hendrerit elementum. Fusce auctor metus non ligula tincidunt, id gravida | ||
| odio sollicitudin. | ||
`), | ||
|
||
footer: pug.compile(` | ||
footer.footer | ||
p.footer-year © 2024 Sample | ||
p.footer | ||
a(href="/terms") Terms | ||
a(href="/privacy") Privacy | ||
`) | ||
}; | ||
|
||
export function RealWorldPage(name: string, purchases: any[]) { | ||
const head = templates.head({ title: 'Real World Example' }); | ||
const purchasesHtml = purchases | ||
.map((purchase) => | ||
templates.purchase({ | ||
name: purchase.name, | ||
price: purchase.price, | ||
quantity: purchase.quantity | ||
}) | ||
) | ||
.join(''); | ||
|
||
const mainContent = templates.main({ | ||
name, | ||
children: ` | ||
<h2>Purchases</h2> | ||
<div class="purchases">${purchasesHtml}</div> | ||
${templates.userProfile({ name })} | ||
${templates.sidebar()} | ||
${templates.pageContent()} | ||
` | ||
}); | ||
|
||
return templates.layout({ | ||
head, | ||
children: ` | ||
<div> | ||
${mainContent} | ||
${templates.footer()} | ||
</div> | ||
` | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@kitajs/bench-html-pug", | ||
"version": "1.0.0", | ||
"private": true, | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"dependencies": { | ||
"pug": "^3.0.2", | ||
"tslib": "^2.8.1", | ||
"typescript": "^5.7.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.1", | ||
"@types/pug": "^2.0.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"outDir": "dist", | ||
"module": "Node16", | ||
"target": "ESNext", | ||
"jsx": "react-jsx", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jsx isn't needed here |
||
"jsxImportSource": "@kitajs/html", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true | ||
}, | ||
"include": ["index.ts"], | ||
"exclude": ["dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<div> | ||
<title>Real World Example</title | ||
><meta name="description" content="A description" /><meta | ||
name="keywords" | ||
content="some, keywords" | ||
/><meta name="author" content="Some Author" /><meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/><link rel="stylesheet" href="styles.css" /> | ||
<script src="script.js"></script> | ||
<meta name="twitter:card" content="summary" /><meta | ||
name="twitter:site" | ||
content="@site" | ||
/><meta name="twitter:title" content="Title" /><meta | ||
name="twitter:description" | ||
content="A description" | ||
/><meta name="twitter:creator" content="@creator" /><meta | ||
name="twitter:image" | ||
content="image.jpg" | ||
/><meta content="Title" /><meta content="website" /> | ||
<script src="https://cdn.jsdelivr.net/npm/axios-cache-interceptor@1/dev/index.bundle.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/axios-cache-interceptor@1/dist/index.bundle.js"></script> | ||
</div> | ||
</head> | ||
<body> | ||
<div> | ||
<main class="main"> | ||
<header class="header"> | ||
<h1 class="header-title">Hello Sample</h1> | ||
<nav class="header-nav"> | ||
<ul class="header-ul"> | ||
<li class="header-item"><a href="/">Home</a></li> | ||
<li><a href="/about">About</a></li> | ||
</ul> | ||
</nav> | ||
</header> | ||
<h2>Purchases</h2> | ||
<div class="purchases"> | ||
<div class="purchase purchase-card"> | ||
<div class="purchase-name">Purchase number 1</div> | ||
<div class="purchase-price">0</div> | ||
<div class="purchase-quantity">0</div> | ||
</div> | ||
</div> | ||
<section class="user-profile"> | ||
<h2 class="user-profile title">User Profile: Sample</h2> | ||
<p class="user-profile info">Email: [email protected]</p> | ||
<p class="user-profile info">Address: 123 Main St, City, Country</p> | ||
<p class="user-profile info">Phone: 123-456-7890</p> | ||
</section> | ||
<aside class="sidebar"> | ||
<h2 class="purchase title">Recent Purchases</h2> | ||
<ul class="purchase list"> | ||
<li class="purchase-preview">Purchase number 1 - $0.00</li> | ||
</ul> | ||
</aside> | ||
<div class="page-content"> | ||
<h2 class="title mb-4 h2">Welcome to our store</h2> | ||
<p class="p text mb-0"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis magna | ||
id dolor ultricies, eget pretium ligula sodales. Cras sit amet turpis nec | ||
lacus blandit placerat. Sed vestibulum est sit amet enim ultrices rutrum. | ||
Vivamus in nulla vel nunc interdum vehicula. | ||
</p> | ||
<p class="p text mb-0"> | ||
Pellentesque efficitur tellus id velit vehicula laoreet. Proin et neque ac | ||
dolor hendrerit elementum. Fusce auctor metus non ligula tincidunt, id gravida | ||
odio sollicitudin. | ||
</p> | ||
</div> | ||
</main> | ||
<footer class="footer"> | ||
<p class="footer-year">© 2024 Sample</p> | ||
<p class="footer"><a href="/terms">Terms</a><a href="/privacy">Privacy</a></p> | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this isn't the intended use for DX pug; please write it in a way that actually utilizes .pug files.