Git Product home page Git Product logo

Comments (4)

jgm avatar jgm commented on September 26, 2024

Look at this part of index.yaml:

    data     : 
        title   : FROM first-post.yaml
        body    : FROM first-post.yaml

This tells yst to populate the both the title and the body template variables with the contents of first-post.yaml. Now, this yaml file contains a yaml object with two fields, title and body. So both title and body get assigned a yaml mapping with two fields.

You can fix this, I think, by doing the following in index.yaml:

    post     : 
        title   : FROM first-post.yaml
        body    : FROM first-post.yaml

Then, in your string template, use $post.title$ and $post.body$ where you now have $title$ and $body$.

from yst.

manolomartinez avatar manolomartinez commented on September 26, 2024

Thank you. That doesn't seem to work. second-post.html is now:

<html>
<head>
   <title>My Website - Second Post</title>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link rel="stylesheet" type="text/css" href="css/screen.css" />
   <link rel="stylesheet" type="text/css" media="print" href="css/print.css" />
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
   <script src="js/nav.js" type="text/javascript"></script>
</head>
<body>
  <div id="doc3" class="yui-t1">
    <div id="yui-main">
      <div id="maincol" class="yui-b">
<h1 id="section"></h1>
      </div>
    </div>
    <div id="nav" class="yui-b first">
<ul class="nav"
><li
  ><a href="index.html"
    >Hola</a
    ></li
  ><li class="active"
  ><a href="#"
    >Blog &#187;</a
    ><ul class="active"
    ><li
      ><a href="first-post.html"
    >First Post</a
    ></li
      ><li class="current"
      ><a href="second-post.html"
    >Second Post</a
    ></li
      ></ul
    ></li
  ></ul
>
    </div>
  </div>
</body>
</html>

That is, no body and no title. I've also tried:

data:
    post:
        title: FROM first-post.yaml
        body: FROM first-post.yaml

This prints the string "FROM first post.yaml" at both title and body.

from yst.

jgm avatar jgm commented on September 26, 2024

Sorry, I didn't think it through. You're doing something a bit strange. Yst is designed to use yaml files like databases -- so, the files should be yaml lists of objects, not yaml objects as in your case.

Why don't you make each post a string template file, or just a plain markdon file? So, instead of first-post.yaml, you'd have first-post.txt.

# My first post

This is my first post.

index.yaml would then be:

- url      : index.html 
  title    : Hola
  template : index.st
- Blog:
  - url      : first-post.html
    title    : First Post
    source : first-post.txt
  - url      : second-post.html
    title    : Second Post
    source     : second-post.txt 

from yst.

manolomartinez avatar manolomartinez commented on September 26, 2024

The main reason is that I was thinking of using a somewhat complicated template, with space for comments, and I thought it would be easier if I had some control over what I was passing to the different parts of the template, as opposed to just a block that includes title, date, body, etc.

I'll try to make it work in the way you suggest. Thanks.

from yst.

Related Issues (20)

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.