Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Chase Wilson

    Hello, I'm trying to make a macro with a default argument, but I get an error

    {% macro highlight_scripts(languages=["rust", "ini"]) %}
    {% endmacro highlight_scripts %}
    * Failed to parse "templates\\macros.html"
     --> 6:38
    6 | {% macro highlight_scripts(languages=["rust", "ini"]) %}␊
      |                                      ^---
      = expected an integer, a float, a string, or `true` or `false`

    Can macros not support all literal types?

    Chase Wilson
    And is there a way to construct null values / what's the best way to do optional macro params
    Fabian Würfl
    Is it possible to call rust functions from within the templates? (currently calling {{ my_object.some_function() }} results in a template error :/)

    I've got a data structure that looks like this:

    {"headers":["Filename"," Duration"],"records":[["hbs001-wie-kamen-die-wolken-zu-ihren-namen.mp3","0:07:45.214694"],["hbs001-wie-kamen-die-wolken-zu-ihren-namen.opus","0:07:45.180583"],["hbs002-der-blitz.mp3","0:08:58.044082"],["hbs002-der-blitz.opus","0:08:58.008500"],["hbs002-die-farben-des-himmels.mp3","0:11:41.152653"],["hbs002-die-farben-des-himmels.opus","0:11:41.111938"],["hbs003-wie-entsteht-regen.mp3","0:12:04.741224"],["hbs003-wie-entsteht-regen.opus","0:12:04.720833"],["hbs004-der-regenbogen.mp3","0:08:19.591837"],["hbs004-der-regenbogen.opus","0:08:19.547833"],["hbs005-wie-schwer-ist-luft.mp3","0:10:22.471837"],["hbs005-wie-schwer-ist-luft.opus","0:10:22.431438"],["hbs006-der-luftdruck-und-das-wetter.mp3","0:08:09.952653"],["hbs006-der-luftdruck-und-das-wetter.opus","0:08:09.910458"],["hbs007-der-geruch-des-regens.mp3","0:06:58.089796"],["hbs007-der-geruch-des-regens.opus","0:06:58.052604"],["hbs008-der-blitz.mp3","0:08:48.248163"],["hbs008-der-blitz.opus","0:08:48.207313"],["hbs009-das-gerausch-des-gewitters.mp3","0:07:10.654694"],["hbs009-das-geräusch-des-gewitters.mp3","0:07:10.654694"],["hbs009-das-gerausch-des-gewitters.opus","0:07:10.634167"],["hbs009-das-geräusch-des-gewitters.opus","0:07:10.634167"],["hbs010-der-jetstream.mp3","0:08:17.841633"],["hbs010-der-jetstream.opus","0:08:17.805500"]]}

    How do I select a Duration by Filename? I tried around a lot with filter but it doesn't seem to work for me because it expects a Vec.

    Help me because I have an urgent matter and a simple problem for someone experienced but I am just getting started with Actix with Tera and Rust. Tell me what to do when I copied this example
    I created a sample page.html file in the templates directory and in index.html file I added a menu and css file, in the menu I have link to the href = "page.html" file and of course css does not work and is correctly added and page.html does not open. CSS is correctly added because when I open index in browser CSS and menu works only when I start Actix it doesn't work :/ How to correctly add to Actix with Tera CSS and another HTML page to generate them correctly? Please show small example based on link from GitHub how I can correctly add CSS and another page in html.
    In dependencies I have lastest crates.