improve docstring

This commit is contained in:
Benedikt Bartscher 2024-07-04 23:37:52 +02:00
parent 548094fb85
commit 868fffcf83
No known key found for this signature in database

View File

@ -19,18 +19,27 @@ def asset(
Place the file next to your including python file. Place the file next to your including python file.
Links the file to the app's external assets directory. Links the file to the app's external assets directory.
Example:
```python
# my_custom_javascript.js is a shared asset located next to the including python file.
rx.script(src=rx._x.asset(path="my_custom_javascript.js"))
rx.image(src=rx._x.asset(path="test_image.png", subfolder="subfolder"))
```
Local/Internal assets: Local/Internal assets:
Place the file in the app's assets/ directory. Place the file in the app's assets/ directory.
Example: Example:
```python ```python
rx.script(src=rx._x.asset("my_custom_javascript.js")) # local_image.png is an asset located in the app's assets/ directory. It cannot be shared when developing a library.
rx.image(src=rx._x.asset("test_image.png","subfolder")) rx.image(src=rx._x.asset(path="local_image.png"))
# Explicit shared=False is only needed if you have a local_image.png next to the including python file.
rx.image(src=rx._x.asset(path="local_image.png", shared=False))
``` ```
Args: Args:
path: The relative path of the asset. path: The relative path of the asset.
subfolder: The directory to place the asset in. subfolder: The directory to place the shared asset in.
shared: Whether to expose the asset to other apps. None means auto-detect. shared: Whether to expose the asset to other apps. None means auto-detect.
Raises: Raises: