|
29 | 29 | "#| export\n", |
30 | 30 | "from dataclasses import dataclass, asdict, is_dataclass, make_dataclass, replace, astuple, MISSING\n", |
31 | 31 | "from bs4 import BeautifulSoup, Comment\n", |
32 | | - "from typing import Literal, Optional\n", |
| 32 | + "from collections import UserDict\n", |
| 33 | + "from typing import Literal, Mapping, Optional\n", |
33 | 34 | "\n", |
34 | 35 | "from fastcore.utils import *\n", |
35 | 36 | "from fastcore.xml import *\n", |
|
311 | 312 | "source": [ |
312 | 313 | "#| export\n", |
313 | 314 | "def ft_html(tag: str, *c, id=None, cls=None, title=None, style=None, attrmap=None, valmap=None, ft_cls=None, **kwargs):\n", |
314 | | - " ds,c = partition(c, risinstance(dict))\n", |
| 315 | + " ds,c = partition(c, risinstance(Mapping))\n", |
315 | 316 | " for d in ds: kwargs = {**kwargs, **d}\n", |
316 | 317 | " if ft_cls is None: ft_cls = fh_cfg.ft_cls\n", |
317 | 318 | " if attrmap is None: attrmap=fh_cfg.attrmap\n", |
|
377 | 378 | "ft_html('a', {'@click.away':1})" |
378 | 379 | ] |
379 | 380 | }, |
| 381 | + { |
| 382 | + "cell_type": "code", |
| 383 | + "execution_count": null, |
| 384 | + "id": "979e9bc8614fb3c1", |
| 385 | + "metadata": {}, |
| 386 | + "outputs": [ |
| 387 | + { |
| 388 | + "data": { |
| 389 | + "text/markdown": "```html\n<a @click.away=\"1\"></a>\n```", |
| 390 | + "text/plain": [ |
| 391 | + "a((),{'@click.away': 1})" |
| 392 | + ] |
| 393 | + }, |
| 394 | + "execution_count": null, |
| 395 | + "metadata": {}, |
| 396 | + "output_type": "execute_result" |
| 397 | + } |
| 398 | + ], |
| 399 | + "source": "ft_html('a', UserDict({'@click.away':1}))" |
| 400 | + }, |
380 | 401 | { |
381 | 402 | "cell_type": "code", |
382 | 403 | "execution_count": null, |
|
0 commit comments