package Gruntmaster::Page::Us::Entry;

use 5.014000;
use strict;
use warnings;
use parent qw/Exporter/;
our @EXPORT_OK = qw/generate/;
our $VERSION = '0.001';

use HTML::Template::Compiled;
use Gruntmaster::Data qw/users user_name user_town user_university user_level/;
use Gruntmaster::Page::Common qw/cook_templates reload_templates/;

my %orig_templates = (
	en => <<'HTML',
<h1><tmpl_var name></h1>
Town: <tmpl_var town><br>
University: <tmpl_var university><br>
Level: <tmpl_var level>
HTML
);

my %templates = cook_templates %orig_templates, us_entry => '<tmpl_var name>';

sub generate{
	%templates = cook_templates %orig_templates, us_entry => '<tmpl_var name>' if reload_templates;
	$_[0] =~ m,^us/([^/]+)\.html$,;
	local $_ = $1;
	my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});

	$htc->param(name => user_name);
	$htc->param(town => user_town);
	$htc->param(university => user_university);
	$htc->param(level => user_level);
	$htc->output;
}

1
