Skip to content

configuration variables could also be managed a level higher #38

Description

@Ducasse

Right now when we write {{{menu}}} in a template and menu is a variable defined in the config file, it does not work because it should be written {{{site.menu}}} because the site holds the configuration and when a message is not found, mustache offers a way to lookup elsewhere.

From a user perspective this is not that nice because there is not difference in the config between {{{title}}} and {{{menu}}} just that internally {{{title}}} is defined on the context

FOMicrodownPageRenderContext >> title

	^ self page title

FOMicrodownPageRenderContext >> site
	
	^ website

Here is the ESUG (working template)

<!DOCTYPE html>
<html lang="en">
  <head profile="http://www.w3.org/2005/10/profile">
  	<link rel="icon" type="image/png" href="{{baseurl}}/images/favicon.png">
  	<meta charset="utf-8">
 	<meta http-equiv="X-UA-Compatible" content="IE=edge">
 	<meta name="viewport" content="width=device-width, initial-scale=1">
	
    	<title>ESUG: {{{title}}}</title>
    	<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="{{baseurl}}theme/style.css">
    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  
  <body>
  <div class="container">
    <nav class="navbar navbar-expand-lg navbar-light">
	<a class="navbar-brand" href="{{baseurl}}">
             <img alt="{{site_name}}" src="{{baseurl}}{{site_logo}}">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myNavbar" aria-controls="myNavbar" aria-expanded="false" aria-label="Toggle navigation">
    		<span class="navbar-toggler-icon"></span>
  	</button>
	
        <!--<div class="container-fluid">-->
            <div class="collapse navbar-collapse" id="myNavbar">
                <ul class="navbar-nav ml-auto">
                    {{# site.menu }}
                    <li id="{{title}}" {{# has_subfiles }}class="nav-item dropdown disabled"{{/ has_subfiles }}>
			<a href="{{url}}" {{# has_subfiles }}class="nav-link dropdown-toggle" id="navbarDropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"{{/ has_subfiles }}>
                            {{ title }}
                        </a>
						
                        {{# has_subfiles }}
                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                             {{# submenu }}
                             <a class="dropdown-item" href="{{url}}">{{ title }}</a>
                             {{/ submenu }}
                        </div>
                        {{/ has_subfiles }}
                   </li>
	           {{/ site.menu }}
		   
                </ul>
            </div>
    </nav>
    
    <div class="row justify-content-center">
        <div class="panel-body col-12" style="margin-top: 30px;">{{{body}}}</div>
    </div>
   </div> 

<footer class="footer">
        This website is developed using <a href="https://github.com/pillar-markup/Foliage">Foliage</a>. Code is available <a href="https://github.com/ESUG/esug.github.io">https://github.com/ESUG/esug.github.io</a>
</footer>


	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
	<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
		var table = document.getElementsByTagName("table");
		for (i=0; i<table.length; i++) {
			table[i].style.border = "";
			table[i].setAttribute("class", "table");		
		}

		var captions = document.getElementsByTagName("figcaption");
		for (i=0; i<captions.length; i++) {
			captions[i].innerHTML=""
		}
</script>
    
</body>
</html>

It would be good to see if we cannot add an error handling mechanism a level higher i.e. in the FOMicrodownPageRenderContext instead of the Site. The error handler could request the website for its properties
and look inside.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions