Git Product home page Git Product logo

probesys / lotemplate Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 1.0 14.15 MB

LOTemplate is document generator used to create documents programatically (ODT, DOCX, PDF) from a template (DOCX or ODT) and a json file.

License: GNU Affero General Public License v3.0

Shell 0.05% Python 40.13% Dockerfile 0.61% HTML 1.28% Rich Text Format 57.85% Makefile 0.09%
document-generator libreoffice text-document

lotemplate's People

Contributors

cyrilus avatar kyrela avatar nathn avatar philippe-levan avatar sparunakian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kibatic

lotemplate's Issues

[BUG] ModuleNotFoundError: No module named 'uno'

Describe the bug

ModuleNotFoundError: No module named 'uno'

To Reproduce

  1. git clone
  2. pip install -r requirements.txt
  3. python lotemplate_cli.py

Expected behavior

program to run

Actual behavior

ModuleNotFoundError: No module named 'uno'

System information

Debian

Version

11.6

Additional context

after manually pip install uno, I get ModuleNotFoundError: No module named 'base'

[FEATURE] add a if/endif syntax in templates

Is your feature request related to a problem? Please describe.

In my templates, I need to display one paragraph or one other according to a value sent by JSON.

The content of these paragraph should stay in the template (and not sent in the JSON).

For example in a status of a company I need a different paragraph if the company is an commercial company or a fundation.

Describe the solution you'd like

I believe we could add a syntax like this in the .odt files 👍

[if $status="SARL"]
This company needs at least 2 or 3 people...
[endif]

[if $status="SA"]
This company needs at least 9 people...
[endif]

then if $status="SARL" then we display the first paragraph and removes the second one.

Describe alternatives you've considered

At the beginning I imagine to send the paragraph values in the JSON, but the text inside the [if xx] [endif] can be long and can contain some formatting. Furthermore, the people that will do the templates will be non technical people. It is easier for them to have these paragraphs inside the odt files.

Additional context

No response

[HELP NEEDED] understanding of function variable

Is your feature request related to a problem? Please describe.

Hi,

When I look at the code, it seems that we can add a "function variable" into a template like $my_var(foo.bar)

Then in my json, I can add the variable "variables":{"my_var(foo.bar)":{"type":"text","value":"my_value"}}

and then all the string $my_var(foo.bar) is replaced by my_value.

Is there another feature associated to these "function variables" or it is just the way to have variables with a more flexible variable name (which is useful for me) ?

Describe the solution you'd like

Not applicable

Describe alternatives you've considered

No response

Additional context

No response

[FEATURE] Better error detection during scanning for if and for statements

Is your feature request related to a problem? Please describe.

A template contained a syntaxe error in a template of 90 pages (and 235 if/endif)

[if [foritem type organe] == MEMBRE DU CS] instead of [if [foritem organe] == MEMBRE DU CS]

As the if statement contains a syntax error, it is not detected during parsing (due to libreoffice limitation, we dont' use a real parser système, we have to use regex for parsing).

Then the only error that is triggered is too_many_endif_found (the if is not detected but the endif is detected).

The error too_many_endif_found cannot give any clue on the line of the error.

Then this very difficult to find the syntax error.

Describe the solution you'd like

The better would be to detect a syntax error on an if statement or a for statement and return an error during the scan with the complete statement in the error message and the page number.

Describe alternatives you've considered

No response

Additional context

No response

[FEATURE] Add for/endfor syntax for loops

Is your feature request related to a problem? Please describe.

I need to display a list of people in a document. They have several properties : names, phone, email...

This can be displayed as bullet points or different paragraph for each people.

Describe the solution you'd like

I imagine a syntax in the word file like

People in company $companyName
[for index, item in people]
People number $index
Civility: [if $item(civility) == Mr]Mister[endif][if $item(civility) == Miss]Miss[endif]
Name : $item(firstName) $item(lastName)
Address : $item(adr.street1) $item(adr.street2) $item(adr.zip)$item(adr.city)
[endfor]

with a json file like

"variables": {
  "companyName": {"type": "text", "value": "Dev Inc."},
  "people": {"type": "array", "value": [
    {
      "firstName": "Corinne",
      "lastName": "Dupont",
      "civility": "Miss",
      "addr": {
        "street1": "5 rue de la paix",
        "street2": "",
        "zip": "38000",
        "city": "Grenoble"
      }
    },
    {
      "firstName": "Robert",
      "lastName": "Durand",
      "civility": "Mr",
      "addr": {
        "street1": "15 place des fêtes",
        "street2": "",
        "zip": "38000",
        "city": "Grenoble",
      },
    }
  ]}
}

And the result would be

People in company Dev Inc.

People number 0
Civility: Miss
Name : Corinne Dupont
Address : 5 rue de la paix, 38000 Grenoble

People number 1
Civility: Mister
Name : Robert Durand
Address : 15 place des fêtes, 38000 Grenoble

Note :

This syntax can work with a simple array or with a dict for the "people" value

Describe alternatives you've considered

No response

Additional context

This syntax is not very easy because the syntax used implies a change in the scanning system of simple vars. But I believe we should not continue to create new prefix like $ or & for each variable type.

[BUG] too_many_endif that should not arrive

Describe the bug

On the scan phase, the following odt file returns a "too_many_endif" error.

Test

[if $odoo(coop_forme_juridique) == SAS] [for $odoo(mandataires_sas)] [if [foritem type] == PP] [foritem nom], [foritem titre] ;  [endif] [endfor]

[endif]

To Reproduce

  1. send the previous file as a template
  2. look a the response

Expected behavior

The template is valid, it should be ok after the scan

Actual behavior

the program returns "too_many_endif"

System information

Debian

Version

1.5.2

Additional context

No response

[FEATURE] html statement

Is your feature request related to a problem? Please describe.

I need to interpret html code inside a odt template

Describe the solution you'd like

It would be great to have a section inside [html] [endhtml] is interpreted

Describe alternatives you've considered

No response

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.