Phyal - 0.4.0 Website

Introducing phyal,


Quickly build websites without the hassle of HTML


I have seen people discouraged by websites because of HTML not being similar to other languages they have seen. So, I made a framework that allows you to make websites using a Python like syntax, in Python, without the trouble of HTML.

You can check it out here today → phyal Replit - phyal GitHub

If you could consider giving the GitHub Repo a Star, that would help me a lot.

You can import phyal like so → import phyal
And in the shell → pip install phyal

Make sure to check out the README.md to learn how to easily use it.


phyal - 0.4.0

  • phyal now has a website that includes documentation! It easily lets you browse around without all of the clutter and gets down to business. Check it out now → https://phyal.vercel.app/ .

phyal - 0.3.1

  • Had to fix an issue on the PyPI side with the description.

phyal - 0.3.0

Big thanks to @Matt-DESTROYER @Carbon32 for their contributions!

  • We just upgraded phyal to its biggest release yet, 0.3.0! Now it can actually be used for bigger projects easily. If you come across any bugs or errors please create an issue, and if you want to fix it yourself send a pull request. Happy coding!

phyal - 0.2.2

  • Added import statement so you can use phyal without the source code

phyal - 0.2.1

  • Merged framework.py and html_generator.py to remove clutter

phyal - 0.2.0

Thanks to @NuclearPasta0 for the suggestion

  • Updated Syntax to make it easier to read

phyal - 0.1.0

Alpha release of phyal to see if it received well.

  • Added a select few elements to use in phyal (more/all will come later)
  • Basic use (could possibly be buggy, in that case message me here on Replit Ask about it

If you have any ideas you can also create a Pull Request or Issue on the GitHub Repo here → GitHub - SalladShooter/phyal: Quickly build websites without the hassle of HTML.

If you notice anything that needs improving please share your feedback! I will credit you if you make a suggestion in the next update.


phyal Made by @SalladShooter - 2024

9 Likes

Nice.
I’d like to give some feedback about the code design, mostly at the Tag and Tags.

I see that the flow with tags is with method chaining a.b().c().d(). To me it feels unnecessary, but if there is a certain reason for this, then okay. I know it is common in JS and other languages.

In Tag, you have an attributes list that can be filled up with the attribute() method. Ignoring the subclasses of Tag for now, why is it a list and why is it filled with attribute()? Why not a dict, or SimpleNamespace, or a combination of the two? Also, a good time to set the attributes would be in __init__(), right? The id() method would also be redundant.

def __init__(self, name, text='', **attributes):
  ...
  self.attributes = attributes

The add_children() method also seems a little strange to me, if children were instead set in __init__(), I feel like it would look nicer.

Having one subclass for each kind of Tag looks really weird and unpythonic. A factory getter on Tags, with a separate dict when a Tag requires some attributes, might be better. Or even forgo the Tags collection and have users directly use Tag().

If you have feedback on my feedback, please share your feedback!

3 Likes

@NuclearPasta0 how exactly would you want this to look, are you talking about it changing the source code or syntax?

1 Like

To change the source code and syntax.

Here’s how the syntax might work.

html_content.append(str(Tag('a', 'Link', my_attr='https://google.com')))
html_content.append(str(
  Tag('p', 'Hello World', id='what', children=[
    Tag('div', children=[
      ...
    ])
  ])
))
# or
html_content = [str(
  Tag(
    'p',
    'Hello World',
    id='what',
    children=[
      Tag('div', children=[
        ...
      ]),
      Tag(...),
    ]
  )
))]

from types import SimpleNamespace

# Tag
def __init__(self, name, text='', /, *, children=(), **attributes):
  ...
  self.children = list(children)
  self.attributes = SimpleNamespace(**attributes)

A benefit of not having Tag subclasses is that you don’t have to account for every tag, and there may be tags that you haven’t implemented I guess.
Also, you may want to do the str() conversion internally, so html_content is of type list[Tag].

P.S.: I don’t know html.

5 Likes

phyal - 0.2.2

  • Added import statement so you can use phyal without the source code
3 Likes

You may be wondering “where is phyal?”, don’t worry, I didn’t give up or forget. I am working on a massive update that will take phyal out of its early test stages to a place where actual projects could get made. I plan on finishing this update by 2024-08-01T05:00:00Z. In the mean time if you want to help out you can check the GitHub to find issues with current updates, add some code of your own, or share your ideas on GitHub.

Have a good day,
@SalladShooter

4 Likes

phyal - 0.3.0

Big thanks to @Matt-DESTROYER @Carbon32 for their contributions!

  • We just upgraded phyal to its biggest release yet, 0.3.0! Now it can actually be used for bigger projects easily. If you come across any bugs or errors please create an issue, and if you want to fix it yourself send a pull request. Happy coding!
2 Likes

phyal - 0.3.1

  • Had to fix an issue on the PyPI side with the description.
1 Like

phyal - 0.4.0

  • phyal now has a website that includes documentation! It easily lets you browse around without all of the clutter and gets down to business. Check it out now → https://phyal.vercel.app/.

If you have any feedback, feel free to share!

The links are cut off:

Also, a lot of text has underlines even though they aren’t links. I think you should get rid of them.

1 Like

@QwertyQwerty88 are the issues fixed now? I can’t tell with sizing as I’m not on desktop but rather an iPad.

The underlines are gone but the links are still cut off.

@QwertyQwerty88 I just changed some code, is it fixed?

nah, it’s still cut off.

Can I see by how much?

I sent a screenshot earlier

You might have to refresh the page, as I have built a few more deployments to try and fix the issue.