You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

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


Maintainers
1

Readme

Fox Template Engine Manual

Install

  1. Open your project in terminal
  2. activate virtual env
  3. 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc