python-fasthtml 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {python-fasthtml-0.2.2/python_fasthtml.egg-info → python-fasthtml-0.2.3}/PKG-INFO +1 -1
  2. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/__init__.py +1 -1
  3. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/components.py +8 -4
  4. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3/python_fasthtml.egg-info}/PKG-INFO +1 -1
  5. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/settings.ini +1 -1
  6. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/CONTRIBUTING.md +0 -0
  7. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/LICENSE +0 -0
  8. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/MANIFEST.in +0 -0
  9. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/README.md +0 -0
  10. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/_modidx.py +0 -0
  11. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/authmw.py +0 -0
  12. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/cli.py +0 -0
  13. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/common.py +0 -0
  14. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/components.pyi +0 -0
  15. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/core.py +0 -0
  16. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/fastapp.py +0 -0
  17. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/ft.py +0 -0
  18. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/js.py +0 -0
  19. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/live_reload.py +0 -0
  20. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/oauth.py +0 -0
  21. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/starlette.py +0 -0
  22. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/svg.py +0 -0
  23. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/toaster.py +0 -0
  24. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/xtend.py +0 -0
  25. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/fasthtml/xtend.pyi +0 -0
  26. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  27. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  28. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/entry_points.txt +0 -0
  29. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/not-zip-safe +0 -0
  30. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/requires.txt +0 -0
  31. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/python_fasthtml.egg-info/top_level.txt +0 -0
  32. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/setup.cfg +0 -0
  33. {python-fasthtml-0.2.2 → python-fasthtml-0.2.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: The fastest way to create an HTML app
5
5
  Home-page: https://github.com/AnswerDotAI/fasthtml
6
6
  Author: Jeremy Howard
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.2"
1
+ __version__ = "0.2.3"
2
2
  from .core import *
3
3
  from .authmw import *
4
4
  from .components import *
@@ -82,7 +82,7 @@ def _fill_item(item, obj):
82
82
  else: attr.pop('checked', '')
83
83
  else: attr['value'] = val
84
84
  if tag=='textarea': cs=(val,)
85
- return FT(tag,cs,attr)
85
+ return FT(tag,cs,attr,void_=item.void_)
86
86
 
87
87
  # %% ../nbs/api/01_components.ipynb
88
88
  def fill_form(form:FT, obj)->FT:
@@ -120,7 +120,7 @@ def __getattr__(tag):
120
120
 
121
121
  # %% ../nbs/api/01_components.ipynb
122
122
  _re_h2x_attr_key = re.compile(r'^[A-Za-z_-][\w-]*$')
123
- def html2ft(html):
123
+ def html2ft(html, attr1st=False):
124
124
  """Convert HTML to an `ft` expression"""
125
125
  rev_map = {'class': 'cls', 'for': 'fr'}
126
126
 
@@ -136,13 +136,17 @@ def html2ft(html):
136
136
  for key, value in sorted(elm.attrs.items(), key=lambda x: x[0]=='class'):
137
137
  if isinstance(value,(tuple,list)): value = " ".join(value)
138
138
  key = rev_map.get(key, key)
139
- attrs.append(f'{key.replace("-", "_")}={value!r}' if _re_h2x_attr_key.match(key) else f'**{{{key!r}:{value!r}}}')
139
+ attrs.append(f'{key.replace("-", "_")}={value!r}'
140
+ if _re_h2x_attr_key.match(key) else f'**{{{key!r}:{value!r}}}')
140
141
  spc = " "*lvl*indent
141
142
  onlychild = not cts or (len(cts)==1 and isinstance(cts[0],str))
142
143
  j = ', ' if onlychild else f',\n{spc}'
143
144
  inner = j.join(filter(None, cs+attrs))
144
145
  if onlychild: return f'{tag_name}({inner})'
145
- return f'{tag_name}(\n{spc}{inner}\n{" "*(lvl-1)*indent})'
146
+ if not attr1st or not attrs: return f'{tag_name}(\n{spc}{inner}\n{" "*(lvl-1)*indent})'
147
+ inner_cs = j.join(filter(None, cs))
148
+ inner_attrs = ', '.join(filter(None, attrs))
149
+ return f'{tag_name}({inner_attrs})(\n{spc}{inner_cs}\n{" "*(lvl-1)*indent})'
146
150
 
147
151
  soup = BeautifulSoup(html.strip(), 'html.parser')
148
152
  for c in soup.find_all(string=risinstance(Comment)): c.extract()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: The fastest way to create an HTML app
5
5
  Home-page: https://github.com/AnswerDotAI/fasthtml
6
6
  Author: Jeremy Howard
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = fasthtml
4
- version = 0.2.2
4
+ version = 0.2.3
5
5
  min_python = 3.10
6
6
  license = apache2
7
7
  requirements = fastcore>=1.6.3 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.0.6 python-multipart beautifulsoup4
File without changes