🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

foxTemplateEngine

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

foxTemplateEngine

Template Engine for HTML

2.1.1
PyPI
Maintainers
1

Fox Template Engine Manual

Install

  • Open your project in terminal
  • activate virtual env
  • Input 'pip install foxTemplateEngine'

How to use?

from foxTemplateEngine.template_engine import FoxEngine # transform() is a func for render your template to vanilla HTML

obj = FoxEngine('path', {}) # 'path' - path to template, {} - context
obj.getRenderedTemplateAsText() # getting a rendered template
obj.writeToFile('new_path') # saving to file by path: new_path

Example

Before (project/test.fox)

/body
 % repeat 4 %
 /h1
  {{ context['var'] }}
   START LOOP
   % repeat 2 %
   LOOOOOOOP
   % end %
   END LOOP
 ./h1
 % end %
./body

Start this code

from foxTemplateEngine.template_engine import transform

obj = FoxEngine('test.fox', {
    'var': 'Hello, World!'
})
obj.getRenderedTemplateAsText()
obj.writeToFile('test.html')

"""
function getRenderedTemplateAsText() is called first and only then writeToFile()
"""

After (project/test.html)

<body>
 <h1>
  Hello, World!
   START LOOP
   LOOOOOOOP
   LOOOOOOOP
   END LOOP
 </h1>
 <h1>
  Hello, World!
   START LOOP
   LOOOOOOOP
   LOOOOOOOP
   END LOOP
 </h1>
 <h1>
  Hello, World!
   START LOOP
   LOOOOOOOP
   LOOOOOOOP
   END LOOP
 </h1>
 <h1>
  Hello, World!
   START LOOP
   LOOOOOOOP
   LOOOOOOOP
   END LOOP
 </h1>
</body>

See tests for a better understanding of how the package works!

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts