2

I would like to have the following strucutre in my project:

folder
\_script_1.pl
  mojolicious_ui_script.pl
  HTML
  \_website.html.ep
  CSS
  \_website.css.ep

But I'm just able to get it to work using this default strucutre:

folder
\_script_1.pl
  mojolicious_ui_script.pl
  templates
  \_website.html.ep
    website.css.ep

This is a simplified version of the mojolicious_ui_script.pl I´m using:

use utf8;
use open ':std', ':encoding(UTF-8)';


use Mojolicious::Lite;



get "/" => 'website';

get "/website\.css" => { template => 'website', format => 'css'} => 'website-css';



# app->secret('random string to turn off warnings about no secret');
# app->mode('production'); # stop debug output
app->start('daemon', '-l', 'http://*:3000');

I'm stucked finding a way to solve this, as the documentation between the lite version and normal Mojo is sometimes mixed and I don´t if something can be used on both sides, but anyway trying a lot of things with routes I have not been able to chagne this.

Grinnz
  • 9,093
  • 11
  • 18
nck
  • 1,673
  • 16
  • 40
  • 1
    Why do you have the CSS as a template? Normally you'd have that in your public folder. Or you could just have folders for HTML and CSS inside your template folder. – simbabque Jun 27 '19 at 10:16
  • @simbabque I'm new to the framework and I have not been able to find clear documentation on how should be that done. I´ve just been able to have that code working but I would like to have another structure – nck Jun 27 '19 at 11:48
  • @nck maybe this helps: https://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Static-files "External static files are not limited to a single file extension and will be served automatically from a public directory if it exists." – Chris Jun 27 '19 at 12:34
  • Possible duplicate of [serve static directory from mojolicious other than /public](https://stackoverflow.com/questions/34935367/serve-static-directory-from-mojolicious-other-than-public) – Chris Jun 27 '19 at 12:42
  • 1
    Note that Mojolicious::Lite is a very tiny wrapper around Mojolicious, the only functionality unique to Lite is `group` which is needed to make the DSL work. So you can probably assume any examples for one will be usable for the other. – Grinnz Jun 28 '19 at 17:48

0 Answers0