remove iterable from jinja
This commit is contained in:
parent
be92063421
commit
5e45ca509b
@ -6,8 +6,6 @@
|
|||||||
{% filter indent(width=indent_width) %}
|
{% filter indent(width=indent_width) %}
|
||||||
{%- if component is not mapping %}
|
{%- if component is not mapping %}
|
||||||
{{- component }}
|
{{- component }}
|
||||||
{%- elif "iterable" in component %}
|
|
||||||
{{- render_iterable_tag(component) }}
|
|
||||||
{%- elif component.children|length %}
|
{%- elif component.children|length %}
|
||||||
{{- render_tag(component) }}
|
{{- render_tag(component) }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
@ -40,30 +38,6 @@
|
|||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{# Rendering condition component. #}
|
|
||||||
{# Args: #}
|
|
||||||
{# component: component dictionary #}
|
|
||||||
{% macro render_condition_tag(component) %}
|
|
||||||
{ {{- component.cond_state }} ? (
|
|
||||||
{{ render(component.true_value) }}
|
|
||||||
) : (
|
|
||||||
{{ render(component.false_value) }}
|
|
||||||
)}
|
|
||||||
{%- endmacro %}
|
|
||||||
|
|
||||||
|
|
||||||
{# Rendering iterable component. #}
|
|
||||||
{# Args: #}
|
|
||||||
{# component: component dictionary #}
|
|
||||||
{% macro render_iterable_tag(component) %}
|
|
||||||
<>{ {%- if component.iterable_type == 'dict' -%}Object.entries({{- component.iterable_state }}){%- else -%}{{- component.iterable_state }}{%- endif -%}.map(({{ component.arg_name }}, {{ component.arg_index }}) => (
|
|
||||||
{% for child in component.children %}
|
|
||||||
{{ render(child) }}
|
|
||||||
{% endfor %}
|
|
||||||
))}</>
|
|
||||||
{%- endmacro %}
|
|
||||||
|
|
||||||
|
|
||||||
{# Rendering props of a component. #}
|
{# Rendering props of a component. #}
|
||||||
{# Args: #}
|
{# Args: #}
|
||||||
{# component: component dictionary #}
|
{# component: component dictionary #}
|
||||||
|
@ -66,7 +66,7 @@ from reflex.vars.base import (
|
|||||||
Var,
|
Var,
|
||||||
cached_property_no_lock,
|
cached_property_no_lock,
|
||||||
)
|
)
|
||||||
from reflex.vars.function import ArgsFunctionOperation, FunctionStringVar
|
from reflex.vars.function import FunctionStringVar
|
||||||
from reflex.vars.object import ObjectVar
|
from reflex.vars.object import ObjectVar
|
||||||
from reflex.vars.sequence import LiteralArrayVar
|
from reflex.vars.sequence import LiteralArrayVar
|
||||||
|
|
||||||
@ -2399,26 +2399,6 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|||||||
return render_dict_to_var(tag.render(), imported_names)
|
return render_dict_to_var(tag.render(), imported_names)
|
||||||
return Var.create(tag)
|
return Var.create(tag)
|
||||||
|
|
||||||
if "iterable" in tag:
|
|
||||||
function_return = Var.create(
|
|
||||||
[
|
|
||||||
render_dict_to_var(child.render(), imported_names)
|
|
||||||
for child in tag["children"]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
func = ArgsFunctionOperation.create(
|
|
||||||
(tag["arg_var_name"], tag["index_var_name"]),
|
|
||||||
function_return,
|
|
||||||
)
|
|
||||||
|
|
||||||
return FunctionStringVar.create("Array.prototype.map.call").call(
|
|
||||||
tag["iterable"]
|
|
||||||
if not isinstance(tag["iterable"], ObjectVar)
|
|
||||||
else tag["iterable"].items(),
|
|
||||||
func,
|
|
||||||
)
|
|
||||||
|
|
||||||
props = {}
|
props = {}
|
||||||
|
|
||||||
special_props = []
|
special_props = []
|
||||||
|
Loading…
Reference in New Issue
Block a user