Unindent jinja template code (#1001)
This commit is contained in:
parent
01aac494dd
commit
8c42c99ecf
@ -3,7 +3,7 @@
|
||||
{% block export %}
|
||||
export default function Document() {
|
||||
return (
|
||||
{{utils.render(document, indent_width=4)}}
|
||||
{{utils.render(document, indent_width=0)}}
|
||||
)
|
||||
}
|
||||
{% endblock %}
|
@ -67,7 +67,7 @@ export default function Component() {
|
||||
{% endfor %}
|
||||
|
||||
return (
|
||||
{{utils.render(render, indent_width=4)}}
|
||||
{{utils.render(render, indent_width=0)}}
|
||||
)
|
||||
}
|
||||
{% endblock %}
|
@ -1,8 +1,8 @@
|
||||
{# Renderting components recursively. #}
|
||||
{# Rendering components recursively. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{# indent_width: indent width #}
|
||||
{% macro render(component, indent_width=2) %}
|
||||
{% macro render(component, indent_width=0) %}
|
||||
{% filter indent(width=indent_width) %}
|
||||
{%- if component is not mapping %}
|
||||
{{- component }}
|
||||
@ -18,7 +18,7 @@
|
||||
{% endfilter %}
|
||||
{% endmacro %}
|
||||
|
||||
{# Renderting self close tag. #}
|
||||
{# Rendering self close tag. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_self_close_tag(component) %}
|
||||
@ -29,7 +29,7 @@
|
||||
{%- endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{# Renderting close tag with args and props. #}
|
||||
{# Rendering close tag with args and props. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_tag(component) %}
|
||||
@ -46,7 +46,7 @@
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{# Renderting condition component. #}
|
||||
{# Rendering condition component. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_condition_tag(component) %}
|
||||
@ -58,7 +58,7 @@
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{# Renderting iterable component. #}
|
||||
{# Rendering iterable component. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_iterable_tag(component) %}
|
||||
@ -70,7 +70,7 @@
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{# Renderting props of a component. #}
|
||||
{# Rendering props of a component. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_props(props) %}
|
||||
@ -78,7 +78,7 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{# Renderting content with args. #}
|
||||
{# Rendering content with args. #}
|
||||
{# Args: #}
|
||||
{# component: component dictionary #}
|
||||
{% macro render_arg_content(component) %}
|
@ -34,7 +34,7 @@ WEB_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, "web")
|
||||
# The assets subdirectory of the template directory.
|
||||
ASSETS_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, APP_ASSETS_DIR)
|
||||
# The jinja template directory.
|
||||
JINJA_TEMPLATE_DIR = os.path.join(ROOT_DIR, MODULE_NAME, "templates")
|
||||
JINJA_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, "jinja")
|
||||
|
||||
# The frontend directories in a project.
|
||||
# The web folder where the NextJS app is compiled to.
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Pynecone middleware."""
|
||||
|
||||
from .hydrate_middleware import HydrateMiddleware
|
||||
from .logging_middleware import LoggingMiddleware
|
||||
from .middleware import Middleware
|
||||
|
@ -1,38 +0,0 @@
|
||||
"""Logging middleware."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pynecone.event import Event
|
||||
from pynecone.middleware.middleware import Middleware
|
||||
from pynecone.state import State, StateUpdate
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pynecone.app import App
|
||||
|
||||
|
||||
class LoggingMiddleware(Middleware):
|
||||
"""Middleware to log requests and responses."""
|
||||
|
||||
async def preprocess(self, app: App, state: State, event: Event):
|
||||
"""Preprocess the event.
|
||||
|
||||
Args:
|
||||
app: The app to apply the middleware to.
|
||||
state: The client state.
|
||||
event: The event to preprocess.
|
||||
"""
|
||||
print(f"Event {event}")
|
||||
|
||||
async def postprocess(
|
||||
self, app: App, state: State, event: Event, update: StateUpdate
|
||||
):
|
||||
"""Postprocess the event.
|
||||
|
||||
Args:
|
||||
app: The app to apply the middleware to.
|
||||
state: The client state.
|
||||
event: The event to postprocess.
|
||||
update: The current state update.
|
||||
"""
|
||||
print(f"Update {update}")
|
@ -9,8 +9,7 @@ import typer
|
||||
|
||||
from pynecone import constants
|
||||
from pynecone.config import get_config
|
||||
from pynecone.telemetry import pynecone_telemetry
|
||||
from pynecone.utils import build, console, exec, prerequisites, processes
|
||||
from pynecone.utils import build, console, exec, prerequisites, processes, telemetry
|
||||
|
||||
# Create the app.
|
||||
cli = typer.Typer()
|
||||
@ -49,10 +48,10 @@ def init(
|
||||
prerequisites.create_config(app_name)
|
||||
prerequisites.initialize_app_directory(app_name, template)
|
||||
build.set_pynecone_project_hash()
|
||||
pynecone_telemetry("init", get_config().telemetry_enabled)
|
||||
telemetry.send("init", get_config().telemetry_enabled)
|
||||
else:
|
||||
build.set_pynecone_project_hash()
|
||||
pynecone_telemetry("reinit", get_config().telemetry_enabled)
|
||||
telemetry.send("reinit", get_config().telemetry_enabled)
|
||||
|
||||
# Initialize the .gitignore.
|
||||
prerequisites.initialize_gitignore()
|
||||
@ -123,7 +122,7 @@ def run(
|
||||
assert frontend_cmd and backend_cmd, "Invalid env"
|
||||
|
||||
# Post a telemetry event.
|
||||
pynecone_telemetry(f"run-{env.value}", get_config().telemetry_enabled)
|
||||
telemetry.send(f"run-{env.value}", get_config().telemetry_enabled)
|
||||
|
||||
# Run the frontend and backend.
|
||||
try:
|
||||
@ -210,7 +209,7 @@ def export(
|
||||
)
|
||||
|
||||
# Post a telemetry event.
|
||||
pynecone_telemetry("export", get_config().telemetry_enabled)
|
||||
telemetry.send("export", get_config().telemetry_enabled)
|
||||
|
||||
if zipping:
|
||||
console.rule(
|
||||
|
@ -14,7 +14,7 @@ from pynecone import constants
|
||||
from pynecone.config import get_config
|
||||
from pynecone.utils import console, prerequisites, processes
|
||||
from pynecone.utils.build import export_app, setup_backend, setup_frontend
|
||||
from pynecone.watch import AssetFolderWatch
|
||||
from pynecone.utils.watch import AssetFolderWatch
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pynecone.app import App
|
||||
|
@ -67,7 +67,7 @@ class Telemetry(Base):
|
||||
python_version: str = get_python_version()
|
||||
|
||||
|
||||
def pynecone_telemetry(event: str, telemetry_enabled: bool) -> None:
|
||||
def send(event: str, telemetry_enabled: bool) -> None:
|
||||
"""Send anonymous telemetry for Pynecone.
|
||||
|
||||
Args:
|
@ -1,6 +1,6 @@
|
||||
import json
|
||||
|
||||
from pynecone import telemetry
|
||||
from pynecone.utils import telemetry
|
||||
|
||||
|
||||
def versiontuple(v):
|
||||
|
Loading…
Reference in New Issue
Block a user