Skip to content

Commit

Permalink
feat(dom_methods.py,-store.fyre): deleted <pyml> from store.fyre and …
Browse files Browse the repository at this point in the history
…updated the code to instead of raising a error when <slot> is not found, update the html, js and css anyway
  • Loading branch information
SuelenKarbivnychyy committed Aug 1, 2023
1 parent 0b69af2 commit 6d3fb6c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 40 deletions.
12 changes: 7 additions & 5 deletions starfyre/dom_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def is_attribute(name):
inner_css = ""
inner_js = ""

for innerElement in inner_content:
for innerElement in inner_content:
innerElement.parentElement = component
new_html, new_css, new_js = render_helper(innerElement)
inner_html += new_html
Expand Down Expand Up @@ -127,10 +127,12 @@ def is_attribute(name):
component.html = html

#check if inner content of component is being used
if is_slot_used is not True and inner_html != "":
raise Exception("Attention: Your custom component has children. Required <slot> tag at components definition to specify where children component should be inserted.")
else:
return html, css, js
if is_slot_used == False and inner_html != "":
html += inner_html
css += inner_css
js += inner_js

return html, css, js


def render(component: Component) -> str:
Expand Down
15 changes: 6 additions & 9 deletions test-application/parent.fyre
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ def ssr_request():
return "No response"

<pyml>
<span>

<div>
<span>
<div>
<h2> 1 This is just a test </h2>
<p> 2 HTML NODE <p>
<p> 2 HTML NODE </p>
{ssr_request()}
<p> 3 HTML NODE </p>
{ssr_request()}
Expand All @@ -25,16 +24,14 @@ def ssr_request():
<b>
{get_parent_signal()}
</b>
<slot></slot>
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
<div>
This won't be re-rendered

</div>

<slot> </slot>
This won't be re-rendered
</div>
</span>
</pyml>
6 changes: 0 additions & 6 deletions test-application/store.fyre
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ use_parent_signal, set_parent_signal, get_parent_signal = create_signal(2)

use_clock_signal, set_clock_signal, _ = create_signal(0)
---

<pyml>
<div>
<slot></slot>
</div>
</pyml>
11 changes: 0 additions & 11 deletions test-children/__init__.fyre

This file was deleted.

9 changes: 0 additions & 9 deletions test-children/parent.fyre

This file was deleted.

0 comments on commit 6d3fb6c

Please sign in to comment.