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 |
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 typing import Protocol, Optional, TypeVar, Type | |
class Animal(Protocol): | |
name: str | |
@dataclass | |
class Mammal: |
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 pathlib import Path | |
def main(): | |
icon = Path('/favicon.png') | |
static = Path('/static') | |
result = static / icon | |
print(str(result)) | |
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
""" | |
Using an alias for a PEP 593 Annotation with multiple arguments. | |
I'm rewriting my injector. | |
I currently put the injector information in dataclass field metadata. | |
I'd like to allow other callables such as functions, so I'm looking at PEP 593 Annotations, similar to what [the inject package](https://github.com/alecthomas/injector/blob/master/injector/__init__.py#L1116) does. | |
My injection though needs zero or more arguments, sort of like an RxPY pipeline. | |
# Update 1: Changed from Markdown science fiction to using code in a running test |
NewerOlder