Skip to main content

Sneact

Sneact is a python library for building user interfaces.

That's so draft.

Hot new features!

Conditions!

from sneact import Sneact, s, _
from sneact.cond import when, when_not, then
from sneact.html import div, p

scope = {
    "ok_text": "Hello!",
    "not_text": "Hello not!",
    "show_text": True
}
page = (+Sneact(scope)
    <<div>>_
        @when(s.show_text, +then
            <<p>> s.ok_text <<-p>>_
        )
        @when_not(s.show_text, +then
            <<p>> s.not_text <<-p>>_
        )
    <<-div>>_
)
Result:
<div>
<p>Hello!</p>
</div>

Loops!

from sneact import Sneact, s, _
from sneact.html import div, img
from sneact.loop import for_each, do, item

scope = {
    "images": ["cat.png", "dog.png", "frog.png"]
}
page = (+Sneact(scope)
    <<div>>_
        @for_each(s.images, +do
            <<img(src=item)>>_
        )
    <<-div>>_
)
Result:
<div>
<img src=cat.png>
<img src=dog.png>
<img src=frog.png>
</div>

Example 1

Python code

from sneact import Sneact, s, _
from sneact.html import div, p, img

scope = {
    "title": "Tiger",
    "subtitle": "About tigers",
    "image": '"tiger.png"',
}
home_page = (+Sneact(scope)
    <<div>>_
        <<p>> s.title <<-p>>_
        <<p>> s.subtitle <<-p>>_
        <<div>>_
            <<p>> s.text <<-p>>_
            <<img(src=s.image)>>_
        <<-div>>_
    <<-div>>_
)
scope["text"] = "Hello tigers. We love Tigers."
result = home_page.as_html()

Resulting html

<div>
<p>Tiger</p>
<p>About tigers</p>
<div>
<p>Hello tigers. We love Tigers.</p>
<img src="tiger.png">
</div>
</div>

Pytest code link

Example 2

Python code

from sneact import Sneact, s, _
from sneact.html import p, h1, header, footer

scope = {}
page = (+Sneact(scope)
    <<header>>_
    	**s.header
    <<-header>>_
    <<p>> "Lorem you know" <<-p>>_
    <<footer>>_
    	**s.footer
    <<-footer>>_
)
scope["header"] = (+Sneact(scope)
    <<h1>> "Page" <<-h1>>_
)
scope["footer"] = (+Sneact(scope)
    <<p>> "Copyright Kiselev Nikolay 2020" <<-p>>_
)
result = page.as_html()

Resulting html

<header>
<h1>Page</h1>
</header>
<p>Lorem you know</p>
<footer>
<p>Copyright Kiselev Nikolay 2020</p>
</footer>

Pytest code link

Metadata

Release files for sneact 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sneact 0.1.1
File Size Uploaded Provenance Actions
sneact-0.1.1.tar.gz 6.3 kB Without provenance Details for sneact-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sneact 0.1.1
File Interpreter ABI Platform Actions
sneact-0.1.1-py3-none-any.whl Python 3 none any Details for sneact-0.1.1-py3-none-any.whl

Total release size: 12.6 kB

Release files / sneact-0.1.1.tar.gz

Download URL sneact-0.1.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
105a42055092e68074c290f1195ceb5a1ceb48e73be679ea6ca38f7492c82cc9
BLAKE2b-256 checksum
How to use checksums
df54b81d21d2f3cda8e64821f64d199c0a092214ba1f1773e3204e666d4939dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-7630-generic

Release files / sneact-0.1.1-py3-none-any.whl

Download URL sneact-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07c5c21a44e5fc88884694dacb54755dd087e984629321b88b5a31af5dc00a7c
BLAKE2b-256 checksum
How to use checksums
827c2eb83a17080a1e58d40fb657c410763086b3d21c829ac0939a7577e7469b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-7630-generic

Security for sneact 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page