mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-08 17:15:45 +00:00
Add std
This commit is contained in:
5
Templates/web/src/components/counter.tcross
Normal file
5
Templates/web/src/components/counter.tcross
Normal file
@@ -0,0 +1,5 @@
|
||||
var count = 0;
|
||||
func Components.Counter()
|
||||
{
|
||||
return <p>Count is {++count}</p>;
|
||||
}
|
||||
35
Templates/web/src/components/shell.tcross
Normal file
35
Templates/web/src/components/shell.tcross
Normal file
@@ -0,0 +1,35 @@
|
||||
func Components.Shell(title,pages,body)
|
||||
{
|
||||
return <!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>%PROJECT_NAME% - {title}</title>
|
||||
<link rel="stylesheet" href="./css/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>%PROJECT_NAME%</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<?code
|
||||
each(var item : pages)
|
||||
{
|
||||
?>
|
||||
<li><a <?code if(item.active) { ?> aria-current="page" <?code } ?> href="<?expr Net.Http.UrlPathEncode(item.route) ?>"><?expr Net.Http.HtmlEncode(item.text) ?></a></li>
|
||||
<?code
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<h1><?expr Net.Http.HtmlEncode(title) ?></h1>
|
||||
<?body?>
|
||||
<?end?>
|
||||
<footer>
|
||||
<p>Created using <a href="https://crosslang.tesseslanguage.com/">CrossLang</a> and <a href="https://simplecss.org/">SimpleCSS</a></p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>;
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
var count = 0;
|
||||
func main(args)
|
||||
{
|
||||
Net.Http.ListenSimpleWithLoop(Router,4206);
|
||||
Net.Http.ListenSimpleWithLoop((ctx)=>{
|
||||
if(ctx.Path == "/")
|
||||
{
|
||||
ctx.WithMimeType("text/html").SendText(Pages.Index());
|
||||
return true;
|
||||
}
|
||||
else if(ctx.Path == "/simple.min.css")
|
||||
{
|
||||
ctx.WithMimeType("text/css").SendBytes(embed("simple.min.css"));
|
||||
return true;
|
||||
}
|
||||
else if(ctx.Path == "/favicon.ico")
|
||||
{
|
||||
ctx.WithMimeType("image/x-icon").SendBytes(embed("favicon.ico"));
|
||||
return true;
|
||||
}
|
||||
},4206);
|
||||
}
|
||||
Reference in New Issue
Block a user