Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
export code INSIDE an ^included^ note (Read 3349 times)
Demogorgon
Full Member
*
Offline



Posts: 71

export code INSIDE an ^included^ note
May 28th, 2015, 12:20am
 
Here's some code from a note that is ^included^ as top boilerplate:
     <nav class="blog-nav">
     ^include("^value($blogNav(current))^","plain-text")^
     </nav>

The note that is included, which is denoted above by ^value($blogNav(current))^, itself contains some export markup, i.e., stuff with carets around them. Stuff like this:

     <a class="blog-nav-item" href="^url(categories)^">Categories</a>

As you know, this markup does not get converted into what I need. What's the solution?

Also, what's the best way to embed the differing navbar html using TB?  Shall we ^include^ separate notes, one for each of the different navbar setups (i.e., in order to indicate the active tab)? Or shall paste the four or five lines of navbar html inside an attribute?
Back to top
 
« Last Edit: May 28th, 2015, 12:48am by Demogorgon »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: export code INSIDE an ^included^ note
Reply #1 - May 28th, 2015, 4:27am
 
The post is a bit hard to follow and appears to refer ("As you know…") to previous unreferenced discussion (off forum?).

By 'current' can you confirm you are referring to the current designator, as opposed to a note called 'current'. Over the years I've done a number of very complex exports and have rarely (ever?) needed to use current, which leads me to wonder if that's needed here. Either way, it should resolve to something.

Although $blogNav is a valid attribute name, I wonder if it is a typo. Nprmal/suggested naming of attributes is to use CamelCase, i.e. $BlogNav. The two names resolve to different attributes so a mis-cased character would break your export code.

If you are trying to link to a note called 'categories', this would be better syntax:

    <a class="blog-nav-item" href="^url("categories")^">Categories</a>

Best practice - in terms of helping TB's parser, is that we quote $Path or $Name values but not designators (e.g. 'current'). If $name isn't working as a reference, it may help to use the complete $Path to 'categories'.

"...this markup does not get converted into what I need." This is unclear. Are you saying the ^export^ code isn't being evaluated at all. Do you see:
  • The ^code^ being exported verbatim.
  • A blank where the code or its output would be.
  • Output, but with the wrong/unexpected values.
It would help if you could post what you get and what you expected to get. for instance, you appear to refer to a note called 'categories'. If there is more than one such note (or aliases) TB my point to the first such by $OutlineOrder. Ma,king a reference by $Path rather than $Name should resolve such an issue.

Just going by what you've stated there's little else to infer here. Missing from your post is whether this is code that was working and now doesn't or is new code you're working on. If it was working, it would be useful to know what changed just before the breakage. It would be also useful to see the output or a small TBC illustrating the code in context.

Hope that helps! I'll also move this thread to a more appropriate sub-forum so it gets seen by those look at/versed in export.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Demogorgon
Full Member
*
Offline



Posts: 71

Re: export code INSIDE an ^included^ note
Reply #2 - May 28th, 2015, 5:07pm
 
Thanks a bunch Mark.  I'm so sorry that my post was so unclear.  I was delirious (with fatigue) when I wrote it.  I see now how it would be hard to decipher.

So I have a template, “blogPage,” that looks like this:

^include(bsBlogTop)^
<div class="row">
<div class="col-sm-8 blog-main">
     ^if($ChildCount)^
           ^include(this,blogPost)^
           ^children(blogPost)^
     ^else^
           ^include(this,blogPost)^  
     ^endif^
^include(bsBlogBottom)^

The boilerplate referred to here, “bsBlogTop,” looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
[…]
</head>
<body>
<div class="blog-masthead">
     <div class="container">
     <nav class="blog-nav">
     ^include("^value($blogNav(current))^","plain-text")^
     </nav>
  </div>
</div>
[…]

Now, each of the top-level notes I want to export (designated by current above) has a different value for $blogNav. [Mark: If I don’t use `current' here, then I get a blank line here on export.] The value of $blogNav is the name of a note. There are four of these notes: bsBlogNavHome, bsBlogNavCats, bsBlogNavArchives, and bsBlogNavAbout. Each one has different navbar code, and the whole purpose of doing all this is to have a different navbar for each of the top-level pages.

For example, here’s the content of bsBlogNavCats:

<a class="blog-nav-item" href="^url(home)^">Home</a>
<a class="blog-nav-item active" href="#">Categories</a>
<a class="blog-nav-item" href="^url(archives)^">Archives</a>
<a class="blog-nav-item" href="^url(About Mapself)^">About</a>

When viewing the categories page, then, the categories tab will be highlighted and scroll to top.

That’s it!

The problem is this line in the included note:

^include("^value($blogNav(current))^","plain-text")^

For the sake of simplicity, we can change this to its evaluation:

^include("^value(bsBlogNavCats)^","plain-text")^

The problem is that none of the TB markup inside bgBlogNavCats gets evaluated.  To answer your question, I see the ^code^ exported verbatim.  The final export is literally this:

<a class="blog-nav-item" href="^url(home)^">Home</a>
<a class="blog-nav-item active" href="#">Categories</a>
<a class="blog-nav-item" href="^url(archives)^">Archives</a>
<a class="blog-nav-item" href="^url(About Mapself)^">About</a>

Rather than this:

<a class="blog-nav-item active" href="#">Home</a>
<a class="blog-nav-item" href="categories.html">Categories</a>
<a class="blog-nav-item" href="archives.html">Archives</a>
<a class="blog-nav-item" href=“about.html”>About</a>

This is the problem I am trying to solve: When a note that I ^include^ itself contains another ^include^, how can I make sure the latter gets rendered from TB ^…^ code into html code?

PS—If there is a more elegant way of assigning different navbar code to notes (besides assigning a different template to each), let me know!  Your atbref is a masterpiece and I've studied it in depth but I can't see a solution for this inside your TBX.
Back to top
 
« Last Edit: May 28th, 2015, 5:09pm by Demogorgon »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: export code INSIDE an ^included^ note
Reply #3 - May 28th, 2015, 5:34pm
 
One instant HTML error (not necessarily affecting TB) is the bsblogTop. You should be inserting a <div> and not a full HTML page. If that doesn't make sense, I'd suggest reading up on the rules of HTML coding as that's too big a topic to take on here. So, I reckon the code should be just:

<div class="blog-masthead">
    <div class="container">
    <nav class="blog-nav">
    ^include("^value($blogNav(current))^","plain-text")^
    </nav>
 </div>
</div>


Notes on current - your explanation makes sense but I only questioned this in the same way I would if it were my code. It can be useful to know the code needs to be there.  Looking at the rest…
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: export code INSIDE an ^included^ note
Reply #4 - May 28th, 2015, 5:44pm
 
Based on what you say about ^code^ showing up verbatim, I suspect you may have set up the boilerplate note export settings or the template such that the ^code^ isn't evaluated.  For instance, if the template uses ^text(plain)^ then inline ^code^ isn't evaluated, use ^text^ instead. See more.

I'd check those things aren't a factor before poking further. This sort of problem tends to be a step-by-step plod.

A v6 feature overlooked if migrating from older versions are the HTML & Preview panes of text.

Set the failing boilerplate note to use the export template specified in the ^include^ call and click on the HTML tab.  Does the ^code^ get evaluated or not?
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Demogorgon
Full Member
*
Offline



Posts: 71

Re: export code INSIDE an ^included^ note
Reply #5 - May 28th, 2015, 6:37pm
 
Hi Mark. Regarding the "instant HTML error." My template inserts the necessary top and bottom HTML boilerplate into every document. bsBlogTop is used for EVERY webpage. Is there a better way to insert the necessary …

<!DOCTYPE html>
<html lang="en">
<head>

… code?
Back to top
 
 
  IP Logged
Demogorgon
Full Member
*
Offline



Posts: 71

Re: export code INSIDE an ^included^ note
Reply #6 - May 28th, 2015, 6:41pm
 
In other news … You solved my problem!

My "plain-text" template contained

^value($Text)^

rather than

^text^

Doh!!!

Thanks so much.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: export code INSIDE an ^included^ note
Reply #7 - May 29th, 2015, 3:20am
 
As regards the HTML, the basic HTML5 page structure is this:

<!DOCTYPE html>
<html>
<head>
<title>the page title</title>
<head>
<body>
...
</body>
</html>


All the 'content', the visible page if you will, sits inside <body>. If you have a template that includes some HTML and that template is also a full page you get:

<!DOCTYPE html>
<html>
<head>
<title>the page title</title>
<head>
<body>

<!DOCTYPE html>
<html>
<head>
<title>the page title</title>
<head>
<body>
...
</body>
</html>
...</body>
</html>


Although modern browsers will attempt to render that - and may achieve that - it is not 'valid' HTML and may not show correctly.

If an include only needs to add:

<div class="blog-masthead">
   <div class="container">
   <nav class="blog-nav">
   ^include("^value($blogNav(current))^","plain-text")^
   </nav>
</div>
</div>


Then it its source template should hold only those tags needed and not use <html>, etc. Again, if unclear on that I suggest getting a book on the basics of HTML or finding a website that explains these 'rules' in a manner you follow (different styles suit different types of learner).

Another way to think about designing an include is to start with a single finished page of HTML. In the HTML source code, select and cut the section created as an include and paste that into a blank HTML template note.  Then, change all the literal text that will be created from Tinderbox attributes to the appropriate export code. That way you won't be trying to stuff a whole HTML page inside another one.

Unsure about your output, use the W3C's validation tool and see what it says about the URLs you test.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print