ph7


Nameph7 JSON
Version 0.1.0rc5 PyPI version JSON
download
home_pagehttps://github.com/angrybayblade/ph7
SummaryPython native web templates
upload_time2024-03-16 02:50:51
maintainer
docs_urlNone
authorViraj Patel
requires_python>=3.9, <4
license
keywords html css js templates django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
             <div style="display:flex; align-items: center; justify-content: center;">
    <h1>💧 PH7</h1>
</div>
<div style="display:flex; align-items: center; justify-content: center;">
    Python native HTML templates
</div>

## Why PH7?

* Native to python
* More code modularity
* Easy to write reusable components
* Out of the box editor support
    * Syntax highlighting
    * Code navvigation tools
    * Auto-completion
*  Type safety using MyPy


## Install
```
pip3 install ph7
```

## Quickstart

Write your first block of markup

<!-- {"type": "html", "file": "examples/hello.py"} -->
```python
from ph7.html import body, div, html

template = html(
    body(
        div(
            "Hello, World!",
        )
    )
)

print(template)
```

```html
<html>
  <body>
    <div>Hello, World!</div>
  </body>
</html>
```
<!-- end -->

Or write a CSS class

<!-- {"type": "css", "file": "examples/css_example.py"} -->
```python
from ph7.css import CSSObject


class flex_center(CSSObject):
    """Flex center"""

    display = "flex"
    align_items = "center"
    justify_content = "center"


print(flex_center())
```

```css
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
```
<!-- end -->

Or use python function as JavaScript function


<!-- {"type": "js", "file": "examples/js_example.py"} -->
```python
from ph7.js import as_js, console, document, fetch


async def fetchDog():
    response = await fetch(
        "https://dog.ceo/api/breeds/image/random",
        {"method": "GET"},
    )
    if response.status != 200:
        response_body = await response.text()
        console.log(f"Error fetching dog; {response_body}")
        return
    data = await response.json()
    document.getElementById("image").src = data.message


print(as_js(fetchDog))
```

```js
async function fetchDog() {
  let response = await fetch('https://dog.ceo/api/breeds/image/random', {
    'method': 'GET'
  });
  if (response.status != 200) {
    let response_body = await response.text();
    console.log('Error fetching dog; ' + response_body);
    return;
  };
  let data = await response.json();
  document.getElementById('image').src = data.message;
};
```
<!-- end -->

PH7 is still in beta-development. It will be production ready with following enhancements

- [ ] Remove performance bottlenecks
- [ ] Unit testing support

Further improvements

- [ ] Typed context for type safety

Links:

* [Documentation](http://ph7.angrybayblade.me)
* [Changelog](https://github.com/angrybayblade/ph7/blob/main/docs/CHANGELOG)
* [Issue Tracker](https://github.com/angrybayblade/ph7/issues)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/angrybayblade/ph7",
    "name": "ph7",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9, <4",
    "maintainer_email": "",
    "keywords": "html,css,js,templates,django",
    "author": "Viraj Patel",
    "author_email": "vptl185@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d4/b5/4045fc87e9ffbe5e1a332697afb0a5844df669dac9c7a2af6d365c10ae8e/ph7-0.1.0rc5.tar.gz",
    "platform": null,
    "description": " <div style=\"display:flex; align-items: center; justify-content: center;\">\n    <h1>\ud83d\udca7 PH7</h1>\n</div>\n<div style=\"display:flex; align-items: center; justify-content: center;\">\n    Python native HTML templates\n</div>\n\n## Why PH7?\n\n* Native to python\n* More code modularity\n* Easy to write reusable components\n* Out of the box editor support\n    * Syntax highlighting\n    * Code navvigation tools\n    * Auto-completion\n*  Type safety using MyPy\n\n\n## Install\n```\npip3 install ph7\n```\n\n## Quickstart\n\nWrite your first block of markup\n\n<!-- {\"type\": \"html\", \"file\": \"examples/hello.py\"} -->\n```python\nfrom ph7.html import body, div, html\n\ntemplate = html(\n    body(\n        div(\n            \"Hello, World!\",\n        )\n    )\n)\n\nprint(template)\n```\n\n```html\n<html>\n  <body>\n    <div>Hello, World!</div>\n  </body>\n</html>\n```\n<!-- end -->\n\nOr write a CSS class\n\n<!-- {\"type\": \"css\", \"file\": \"examples/css_example.py\"} -->\n```python\nfrom ph7.css import CSSObject\n\n\nclass flex_center(CSSObject):\n    \"\"\"Flex center\"\"\"\n\n    display = \"flex\"\n    align_items = \"center\"\n    justify_content = \"center\"\n\n\nprint(flex_center())\n```\n\n```css\n.flex-center {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n```\n<!-- end -->\n\nOr use python function as JavaScript function\n\n\n<!-- {\"type\": \"js\", \"file\": \"examples/js_example.py\"} -->\n```python\nfrom ph7.js import as_js, console, document, fetch\n\n\nasync def fetchDog():\n    response = await fetch(\n        \"https://dog.ceo/api/breeds/image/random\",\n        {\"method\": \"GET\"},\n    )\n    if response.status != 200:\n        response_body = await response.text()\n        console.log(f\"Error fetching dog; {response_body}\")\n        return\n    data = await response.json()\n    document.getElementById(\"image\").src = data.message\n\n\nprint(as_js(fetchDog))\n```\n\n```js\nasync function fetchDog() {\n  let response = await fetch('https://dog.ceo/api/breeds/image/random', {\n    'method': 'GET'\n  });\n  if (response.status != 200) {\n    let response_body = await response.text();\n    console.log('Error fetching dog; ' + response_body);\n    return;\n  };\n  let data = await response.json();\n  document.getElementById('image').src = data.message;\n};\n```\n<!-- end -->\n\nPH7 is still in beta-development. It will be production ready with following enhancements\n\n- [ ] Remove performance bottlenecks\n- [ ] Unit testing support\n\nFurther improvements\n\n- [ ] Typed context for type safety\n\nLinks:\n\n* [Documentation](http://ph7.angrybayblade.me)\n* [Changelog](https://github.com/angrybayblade/ph7/blob/main/docs/CHANGELOG)\n* [Issue Tracker](https://github.com/angrybayblade/ph7/issues)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python native web templates",
    "version": "0.1.0rc5",
    "project_urls": {
        "Changelog": "https://github.com/angrybayblade/ph7/blob/main/docs/CHANGELOG.md",
        "Documentation": "http://ph7.angrybayblade.me",
        "Homepage": "https://github.com/angrybayblade/ph7",
        "Issue Tracker": "https://github.com/angrybayblade/ph7/issues"
    },
    "split_keywords": [
        "html",
        "css",
        "js",
        "templates",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4b54045fc87e9ffbe5e1a332697afb0a5844df669dac9c7a2af6d365c10ae8e",
                "md5": "a7e57ae221dfe29ace10acfb7f87f07a",
                "sha256": "69ca2b5561ea66c3852f0caa38dd2fc360bcce361149e56c988af3955b13b25b"
            },
            "downloads": -1,
            "filename": "ph7-0.1.0rc5.tar.gz",
            "has_sig": false,
            "md5_digest": "a7e57ae221dfe29ace10acfb7f87f07a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9, <4",
            "size": 43559,
            "upload_time": "2024-03-16T02:50:51",
            "upload_time_iso_8601": "2024-03-16T02:50:51.540162Z",
            "url": "https://files.pythonhosted.org/packages/d4/b5/4045fc87e9ffbe5e1a332697afb0a5844df669dac9c7a2af6d365c10ae8e/ph7-0.1.0rc5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-16 02:50:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "angrybayblade",
    "github_project": "ph7",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "ph7"
}
        
Elapsed time: 0.41147s