Note that there are some explanatory texts on larger screens.

plurals
  1. POMeteor: Load only .html from specific sub-directory into page
    primarykey
    data
    text
    <p>I'm attempting to create a simple project for rapid prototyping using Meteor, Meteor Router, and Bootstrap.</p> <p><strong>Here's the directory Structure</strong></p> <pre><code>meteor-prototypes/ | |--- .meteor/ |--- prototypes/ | | | |--- example/ | | | |--- example.coffee | |--- example.css | |--- example-index.html | |--- example-more.html | |--- prototypes.coffee |--- index.html |--- smart.json |--- smart.lock </code></pre> <p>The <code>example</code> folder represents a single prototype, reachable at (for example) <code>http://localhost:3000/prototypes/example/</code>. Ideally, you would be able to add another prototype to the project simply by duplicating <code>example/</code> with a new name (e.g. new-example) and visiting <code>http://localhost:3000/prototypes/new-example/</code>.</p> <p>The problem with this is that Meteor, by default, searches the entire project directory for HTML files and loads them all. What I need to do is check which prototype we're viewing based on the URL (through Meteor Router) and load only the .html files in that folder (e.g. <code>example/</code>).</p> <p><strong>Is there a way to tell Meteor to load only .html files in a specific subdirectory? Or another way to accomplish this?</strong></p> <p><strong>For those curious, or in case it helps, here are what each of the files mentioned in the directory structure above contain:</strong></p> <p><strong>index.html</strong></p> <pre><code>&lt;head&gt; &lt;title&gt;desktime-prototypes&lt;/title&gt; &lt;/head&gt; &lt;body&gt; {{ renderPage }} &lt;/body&gt; &lt;template name="home"&gt; &lt;h1&gt;We have the following prototypes available:&lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="/example/"&gt;Example&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/template&gt; </code></pre> <p><strong>prototypes.coffee</strong></p> <pre><code>if (Meteor.isClient) Meteor.Router.add '': 'home' '/:prototype': (params) -&gt; return params '/:prototype/:page': (params) -&gt; return params[1] if (Meteor.isServer) Meteor.startup -&gt; # code to run on server at startup </code></pre> <p><strong>/prototypes/example.coffee</strong></p> <pre><code>if Meteor.isClient Template.example.greeting = -&gt; return "Welcome to prototypes." Template.example.rendered = -&gt; # This function will fire when this specific template gets rendered, # Great place to fire jQuery plugins, or anything else that needs # to happen when the DOM is ready. Template.example.events 'click input' : -&gt; # template data, if any, is available in 'this' alert 'Button clicked!' </code></pre> <p><strong>prototypes/example/example-index.html</strong></p> <pre><code>&lt;template name="example"&gt; &lt;h1&gt;Welcome to the example prototype!&lt;/h1&gt; {{&gt; example-more }} &lt;/template&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload