我正在以一种很大的方式进入Jekyll,并希望将其用作一般的前端开发平台,但是我遇到了Liquid模板语言的局限性,特别是它与Django模板的区别.
我发现了液体继承宝石,它添加了Django中最重要的Extends和Block语法.此博客文章进一步扩展了宝石以适应Jekyll的文件系统:http: //www.sameratiani.com/2011/10/22/get-jekyll-working-with-liquid-inheritance.html
问题是它似乎没有以与Django完全相同的方式实现块,这实际上使得gem无用.
为了理解,我有两个jekyll"布局" - parent.html和child.html.这些都不包含YAML部分.
亲
<html>
{% block foo %} {% endblock %}
</html>
Run Code Online (Sandbox Code Playgroud)
儿童
{% extends _layouts/parent.html %}
{% block foo %}
<div>
Bar comes next:
{% block bar %} {% endblock %}
</div>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
然后我有一个jekyll页面,其中包含一个YAML部分:
---
title: test
---
{% extends _layouts/child.html %}
{% block bar %}My title is {{ page.title }} {% endblock %}
Run Code Online (Sandbox Code Playgroud)
我期待的是:
<html>
<div>
Bar comes next:
My title is test
</div>
</html>
Run Code Online (Sandbox Code Playgroud)
我得到了什么:
<html>
<div>
Bar …Run Code Online (Sandbox Code Playgroud) 我刚刚开始研究Angular,但当我尝试将可重用组件抽象为单独的模块时,传递范围对我来说变得越来越好.
我正在使用一个Angular Youtube模块,这里有https://github.com/arnaudbreton/angular-youtube,但是它非常不合适所以我正在使用新功能,即支持youtube API的事件.
首先,这是来自第三方模块的相关片段(删节):
angular.module('youtube', ['ng'])
.service('youtubePlayerApi', ['$window', '$rootScope', '$log', function ($window, $rootScope, $log) {
var player = $rootScope.$new(true);
player.playerContainer = null;
player.create = function (attrs) {
player.playerId = attrs.id;
player.videoId = attrs.videoId;
return new YT.Player(this.playerId, {
videoId: attrs.videoId,
events:{
onStateChange: function(event){
switch(event.data){
case YT.PlayerState.PLAYING:
attrs.onEvent()
break;
}
}
}
});
};
player.load = function(){
this.playerContainer = player.create();
}
return player;
}])
.directive('youtubePlayer', ['youtubePlayerApi', function (youtubePlayerApi) {
return {
restrict:'A',
scope: {
id:'@',
videoId:'@',
onEvent:'&'
},
link: …Run Code Online (Sandbox Code Playgroud)