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
# We've generally thought of nesting being an interpolation | |
# that called the html "tag function" (now template function) | |
def Sidebar(heading: str, items: list[Any]) -> HTMLTemplate: | |
return t""" | |
<aside> | |
<h1>{heading}</h1> | |
<ul> | |
{html(t"<li>{item}</li>" for item in items}")} | |
</ul> |
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
from dataclasses import dataclass | |
from pathlib import PurePath | |
from typing import Protocol, Callable, Any | |
import pytest | |
from svcs import Container, Registry | |
@dataclass | |
class Registration: |
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
/* | |
Summary: TSX subcomponents don't have access to shortcodes. The | |
this.context.shortcodes.css() function runs, but doesn't put | |
its content into the bundle. | |
*/ | |
export type Context = { | |
// The "this" value has a "context" managed by Preact. |
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
test("should load an Eleventy site", async () => { | |
const elev = new Eleventy("./", "./_site", { | |
dir: { | |
includes: "my_includes", | |
layouts: "my_layouts", | |
}, | |
}); | |
await elev.init(); | |
const d = elev.config.dir; | |
expect(elev.config.dir.includes).toEqual("my_includes"); |
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
from __future__ import annotations | |
from typing import Any | |
from tagstr import Thunk | |
from tagstr.memoize import TagStringArgs, TagStringCallable | |
def immutable_bits(*args: str | Thunk) -> tuple[str | tuple[Any], ...]: | |
bits = [] | |
for arg in args: |
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
import type { FunctionComponent, VNode } from "preact"; | |
import { createContext, render as preactRender } from "preact"; | |
import { expect, test } from "vitest"; | |
export type EleventyContext = { | |
siteTitle: string; | |
}; | |
const Context = createContext<EleventyContext | null>(null); |
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
<h1>Hello Animals</h1> | |
<ng-container *ngIf="isFish(pet)"> | |
<button (click)="pet.swim()">Swim!</button> | |
</ng-container> | |
<ng-container *ngIf="isFish(pet)"> | |
<button (click)="pet.fly()">Fly!</button> | |
</ng-container> |
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
<html> | |
<head> | |
<title>Custom Element Morph</title> | |
<script src="https://unpkg.com/idiomorph"></script> | |
</head> | |
<body> | |
<hello-world name="World"></hello-world> | |
<button id="update">Update</button> | |
<script defer> | |
class HelloWorld extends HTMLElement { |
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
Idiomorph.morph(target, newHTML, {morphStyle: 'innerHTML'}); |
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
"""A broken attempt at a Protocol-based registry. | |
I have a system with replaceable implementations. A ``Heading`` | |
might be asked for on a page, but which one you get depends | |
on some criteria. | |
mypy doesn't seem to like using Protocols at runtime. This | |
small module has 7 errors. | |
""" | |
from dataclasses import dataclass |
NewerOlder