- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
背景
我正在尝试使用 ember.js
及其依赖项构建博客。基本上,我在左侧“导航栏”,内容显示在右侧。像这样的东西:
左边不动,右边不动;此外,左侧还有指向各个页面的链接。
问题
我正在使用 ember.js
来实现帖子的链接,并将帖子呈现到博客内容端。目前,我的实现没有渲染任何东西。下面是代码:
App = Ember.Application.create({});
var posts = [{
id: '0',
title: 'Title and title',
author: {name: 'Author'},
date: new Date('15-11-2014'),
content: 'Work and work.'
},{
id: '1',
title: "Rails is Omakase",
author: { name: "d2h" },
date: new Date('12-27-2012'),
excerpt: "There are lots of à la carte software environments in this world. Places where in order to eat, you must first carefully look over the menu of options to order exactly what you want.",
body: "I want this for my ORM, I want that for my template language, and let's finish it off with this routing library. Of course, you're going to have to know what you want, and you'll rarely have your horizon expanded if you always order the same thing, but there it is. It's a very popular way of consuming software.\n\nRails is not that. Rails is omakase."
}, {
id: '2',
title: "The Parley Letter",
author: { name: "d2h" },
date: new Date('12-24-2012'),
excerpt: "My [appearance on the Ruby Rogues podcast](http://rubyrogues.com/056-rr-david-heinemeier-hansson/) recently came up for discussion again on the private Parley mailing list.",
body: "A long list of topics were raised and I took a time to ramble at large about all of them at once. Apologies for not taking the time to be more succinct, but at least each topic has a header so you can skip stuff you don't care about.\n\n### Maintainability\n\nIt's simply not true to say that I don't care about maintainability. I still work on the oldest Rails app in the world."
}];
/*
This will load the lists for the template to take
*/
App.ApplicationRoute = Ember.Route.extend({
model: function(){
return posts;
}
});
App.Router.map(function(){
this.resource('post', {path: '/posts/:post_id'});
});
App.PostRoute = Ember.Route.extend({
model: function(params){
return posts[params.post_id];
}
});
/*Some small variables that*/
App.name = "Blog name";
App.tag = "TAG";
App.stub = "Stub";
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
body {
padding:50px;
font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
color:#777;
font-weight:300;
}
h1, h2, h3, h4, h5, h6 {
color:#222;
margin:0 0 20px;
}
p, ul, ol, table, pre, dl {
margin:0 0 20px;
}
h1, h2, h3 {
line-height:1.1;
}
h1 {
font-size:28px;
}
h2 {
color:#393939;
}
h3, h4, h5, h6 {
color:#494949;
}
a {
color:#39c;
font-weight:400;
text-decoration:none;
}
a small {
font-size:11px;
color:#777;
margin-top:-0.6em;
display:block;
}
.wrapper {
width:860px;
margin:0 auto;
}
blockquote {
border-left:1px solid #e5e5e5;
margin:0;
padding:0 0 0 20px;
font-style:italic;
}
code, pre {
font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
color:#333;
font-size:12px;
}
pre {
padding:8px 15px;
background: #f8f8f8;
border-radius:5px;
border:1px solid #e5e5e5;
overflow-x: auto;
}
table {
width:100%;
border-collapse:collapse;
}
th, td {
text-align:left;
padding:5px 10px;
border-bottom:1px solid #e5e5e5;
}
dt {
color:#444;
font-weight:700;
}
th {
color:#444;
}
img {
max-width:100%;
}
header {
width:270px;
float:left;
position:fixed;
}
header ul {
list-style:none;
height:40px;
padding:0;
background: #eee;
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
border-radius:5px;
border:1px solid #d2d2d2;
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
width:270px;
}
header li {
list-style-type: none;
}
header ul a {
line-height:1;
font-size:11px;
color:#999;
display:block;
text-align:center;
padding-top:6px;
height:40px;
}
strong {
color:#222;
font-weight:700;
}
header ul li + li {
width:88px;
border-left:1px solid #fff;
}
header ul li + li + li {
border-right:none;
width:89px;
}
header ul a strong {
font-size:14px;
display:block;
color:#222;
}
section {
width:500px;
float:right;
padding-bottom:50px;
}
small {
font-size:11px;
}
hr {
border:0;
background:#e5e5e5;
height:1px;
margin:0 0 20px;
}
footer {
width:270px;
float:left;
position:fixed;
bottom:50px;
}
@media print, screen and (max-width: 960px) {
div.wrapper {
width:auto;
margin:0;
}
header, section, footer {
float:none;
position:static;
width:auto;
}
header {
padding-right:320px;
}
section {
border:1px solid #e5e5e5;
border-width:1px 0;
padding:20px 0;
margin:0 0 20px;
}
header a small {
display:inline;
}
header ul {
position:absolute;
right:50px;
top:52px;
}
}
@media print, screen and (max-width: 720px) {
body {
word-wrap:break-word;
}
header {
padding:0;
}
header ul, header p.view {
position:static;
}
pre, code {
word-wrap:normal;
}
}
@media print, screen and (max-width: 480px) {
body {
padding:15px;
}
header ul {
display:none;
}
}
@media print {
body {
padding:0.4in;
font-size:12pt;
color:#444;
}
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Blog Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<script type="text/x-handlebars">
<!-- Header which is on the right side. -->
<header>
<h1> {{App.name}} </h1>
<h2>{{App.tag}}</h2>
<p> {{App.stub}}</p>
<!-- Links to the main content -->
<h3> Recent Content </h3>
<!-- Ember code to filter through five most recent posts -->
{{#each post in model}}
<li> {{#linkTo "post" this}} {{post.title}} {{/linkTo}}</li>
{{/each}}
</header>
<!-- Footer -->
<footer>
<p><small>Hosted on GitHub Pages — Theme by <a href="https://github.com/orderedlist">orderedlist</a> with heavy modifications from Jeel Shah</small></p>
</footer>
</script>
<!-- Main content for the day. The rest of the content will be on the left
Ember code will surround this (?)
-->
<script type="text/x-handlebars">
<section>
<h3> Welcome to my blog </h3>
<p>
{{outlet}}
</p>
</section>
</script>
</div>
<!-- javascripts -->
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.9.0-beta.1/ember.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
</body>
</html>
我的尝试
我尝试制作两个不同的 Handlebars 脚本,一个是对帖子的引用,即
<script type="text/x-handlebars" id="posts">
<section>
<h3> Welcome to my blog </h3>
<p>
{{outlet}}
</p>
</section>
</script>
但这没有用。我还尝试在整个 div
周围制作一个 Handlebars 脚本,但这也没有用。
如果有人能指出问题所在的正确方向:我将永远欠你的债。谢谢! :)
更新我已经更新了 HTML/js
的代码。可以查看here
最佳答案
你错过了一些关于 ember 的想法 -
命名很重要。您有帖子 - 应该在模型中,然后使用夹具适配器来声明它们。您有一个帖子模板,但没有定义或在您的路由器中的帖子路由。
this.resource("posts", {path: "/posts"}, function(){
this.resource("post", {path: "/:post_id"});
});
您的路由器中没有索引路由。
this.resource("index", {path: "/"}, function() {});
从外观上看,您根本没有 Controller 。(尽管现在看起来您不需要它们)
如果您使用的是 ember,我建议您使用 ember-cli。它将帮助您设置应用程序结构并帮助命名约定。 http://www.ember-cli.com/
学习 ember 教程也没有什么坏处——无论是在 ember 站点本身还是在其他站点上的教程。尝试做一个尽可能最新的代码,因为代码移动得如此之快以至于教程很快就会过时。
链接
{{#each post in model}}
<li> {{#link-to "post" post}} {{post.title}} {{/link-to}}</li>
{{/each}}
所以对于链接 - {{#link-to "template"model}} 其中 template 是模板,model 是你通过链接传递的元素。因此,在您的情况下,它是“发布”模板,并且由于您将模型定义为发布在您使用的每个语句中。通过文档 http://emberjs.com/guides/templates/links/#toc_the-code-link-to-code-helper
关于javascript - 实现 ember js 后网站无法呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26996612/
我有一个 aspx 应用程序。在每个 GET 中,服务器以包含除表格网格之外的所有内容的“基本”html 进行响应。 这个“网格信息”包含在页面中隐藏的输入类型(json 格式)中。 这是设计使然,无
阅读有关 iOS 中 UIViewControllers 更改的文档,我试图弄清楚呈现模态视图 Controller 之间的交互如何在自定义容器 View Controller 内工作。最终,我希望能
我正忙于编写自己的 JSF2 UIComponent 及其相关的渲染器。我所有的 UIComponent 都实现了 ClientBehaviorHolder。我不明白的是如何真正呈现 ClientBe
我正在开发一个使用UIPopoverController的应用程序,我在呈现该弹出窗口时遇到问题,我有一个添加在self.view上的UIView,并在该 View 上添加了一个表格 View ,该表
我有一个简单的应用程序,我想在用户首次登录应用程序时在其中显示一个 PageViewController。他们查看教程后,在下一次加载时不会显示 PageViewController。 但是我收到了以
我正在尝试制作一个小型的backbone.js 应用程序,但在事情的顺序上很挣扎。 在我的 html 文件中,标题中有两个脚本 block : jQuery(function(){
我有一个以模型为来源的表格: $form->setModel("test"); 在模型中,我们可以定义字段类型,例如:boolean 将在表单中制作复选框。 现在我们如何定义呈现为单选按钮的类型? 最
fabricJS 版本 2.2.3 测试 jsFiddle 我正在尝试使用 LabeledRect 子类,但我的问题是,每当我尝试从 JSON 加载它时,它都不会呈现,并且在控制台中也没有出现错误。请
在我的 Xaml 中,我定义了一个资源作为 vehicleDataInput,它提供一些文本框供用户输入数据。如果我没有为它定义一个 x:Key ,它将在我的应用程序中出现并按其应有的方式工作。问题是
我在 React 中创建了一个 Symbol 组件来轻松呈现 HTML Symbols像 euro 这样的名字将呈现 €(€) 或 sum 呈现 ∑(∑). 问题是,如果我只渲染 HTML 代码,我将
我尝试渲染一个 View ,该 View 工作正常,但似乎无法获得传递给它的模型对象。我不知道原因,因为根据所有手册和示例,这应该非常简单。 模型对象 class Race { def dis
我正在尝试为Grails项目添加一个简单功能,类似于youtube,它将允许用户喜欢/不喜欢文章。有一个非常原始的页面来显示带有喜欢的文章和一个使“喜欢”成为可能的 Controller 。 las,
我的应用程序中的第一个 ViewController 子类 UIImagePickerController 然后通过 didFinishPickingMediaWithInfo 回调,我执行以下操作:
我正在做一个简单的 redux/react todo 应用程序。我无法显示待办事项。我能够 console.log 数据,但无法显示它。我做错了什么? 我把文件分开了,这是我的app.js: impo
我正在尝试呈现一个导航 Controller ,它似乎可以工作并呈现导航 Controller 。但是,即使它有效,我仍然不断收到错误? 我的代码 let vc = storyboard.instan
我正在重新创建一个简单版本的 snapchat 应用程序,但遇到了一个恼人的小问题,我似乎无法找到解决办法。 我查看了一些答案,例如 this one但没有运气。 总体概念与 snapchat 用户单
我在呈现警报时遇到问题。我正在使用 UIAlertController。当用户按下提交按钮时,在应用程序执行某些操作时,需要立即显示“请稍候..”的警报。操作完成后,警报将消失。尽管应该在我开始执行操
我只是想用 Kinetic 渲染图像,但没有出现,也没有出现错误。 可以找到 fiddle here . 源代码: $( function() { var stage = new Kineti
我正在使用 Phantomjs 检查我的应用程序。我正在查看的页面包含很多组件,并且由 Angularjs 提供支持。我的测试服务器很慢。在 onLoadFinished 事件中,我使用渲染对网页进行
我有一个变量,它的字符串包含我所有的文档,如下所示: var string = " ReportHelloWorld"; 我想打开一个正确插入和显示此报告的新页面,但不知道如何操作。我该怎么办? 感谢
我是一名优秀的程序员,十分优秀!