如果您在Rails应用程序中使用HAML和SASS,那么您在public/stylesheet/*.ssss中定义的任何模板都将编译为*.css样式表.从您的代码中,您可以使用stylesheet_link_tag按名称提取资产,而无需担心扩展名.
许多人不喜欢在版本控制中存储生成的代码或编译的代码,并且还有理由说public/directory不应包含您不发送给浏览器的元素.
在Rails项目中布置SASS资源时,最好的模式是什么?
我在TextMate中查看首选项,当我们突出显示一些代码并选择时,似乎没有方法将缩进设置为2个空格
Text -> Shift Right
Run Code Online (Sandbox Code Playgroud)
现在它缩进了4个空格但有没有办法让它成为2个?
好的,我真的很喜欢HAML.特别是,我喜欢与RedCloth和BlueCloth的集成,所以我可以使用Markdown和Textile混合我的HAML.
我也喜欢Python和Django.
所以,我想将HAML与Django一起使用.现在,我已经明白有一些尝试克隆Python中的类似HAML的语法(SHPAML等).我试过这些,虽然它们还不错,但我发现我真的只想要真正的HAML.部分原因在于它的语法,还有RedCloth和BlueCloth之类的东西.
所以,我的问题是,如何让HAML和Django一起工作?
我认为,一个解决方案是创建HAML模板,然后在每次更新时使用命令行工具将它们编译为HTML.
问题1:我会遇到任何问题吗?
我也想知道是否有办法让Python和Ruby一起玩.我的一个想法实际上是在分配Ruby流程.这可能是一个坏主意,但是有人对此有任何想法吗?
问题2:使用Python调用真正的Ruby HAML怎么样?
最后,如果有人知道完整的HAML的Python实现,并支持Textile或Markdown,以及明文passthru,那么请告诉我.
问题3:是否有完整的HAML到Python的翻译,包括Markdown或Textile支持?
谢谢!
我是Sass的新手,但我正在尝试为自己创建一个工作流程.我为我的主题设计生成"颜色包",需要为我的mixin指定以下变量.有一个更好的方法吗?:
// folder,filename,extension,repeat,x-pos,y-pos
@mixin background ($folder:style1, $img:file, $type:png, $repeat:no-repeat, $x:0, $y:0) {
background-image: url(./images/#{$folder}/#{$img}.#{$type});
background-repeat: #{$repeat};
background-position: #{$x}px #{$y}px;
}
Run Code Online (Sandbox Code Playgroud)
我这样插入:
#nav {
@include background(style2,myimage,png,repeat-x,10,10);
}
Run Code Online (Sandbox Code Playgroud)
产生这个:
#nav {
background-image: url(./images/style2/myimage.png);
background-repeat: repeat-x;
background-position: 10px 10px;
}
Run Code Online (Sandbox Code Playgroud)
我希望尽可能使用CSS简写,但我遇到输出错误.如果这不是最好的方法,我会感谢任何专家建议.
我只是想尝试格式化一个haml生成的(文本)邮件程序模板,而我在阅读多个换行符时遇到了一些困难.例如:我想过
Dear
= @user.name,
Your username is
= @user.username
Your status is
= @user.status
Run Code Online (Sandbox Code Playgroud)
我曾假设会读取多个换行符,但"您的状态为"行会在用户名正下方的行上显示.(是的,那么多次换行是夸大了我想要多少,但仍然)
所以,问题是:haml短信中的换行符......呃,怎么样?
我有以下代码
%br
= f.label :active, 'Status'
= f.select :active, ['Active','Inactive']
Run Code Online (Sandbox Code Playgroud)
符号:active是布尔类型var.如何为数据库添加匹配Active => 1/True和Inactive => 0/False.
对不起新手问题,但我无法弄清楚.
如何在HAML中为单个Ruby语句使用多行?例如,我想写下面的内容:
- entries = [{
- :title => "The Fellowship of the Ring",
- :body => "We should walk instead of fly"
- }]
!!! 5
%html
%head
%title Blog
%body
#content
- entries.each do |entry|
.entry
%h3.title= entry[:title]
%p.body= entry[:body]
Run Code Online (Sandbox Code Playgroud)
但当然前四行会产生语法错误.
我将staticmatic用于稍后用PHP的模板.有一种奇怪的情况,有些标签属性有单引号,有些则有双引号.我希望他们所有人都有双引号(不是我认为这很重要,但我希望他们这样!)
例如,haml代码:
!!! XML
%html{html_attrs('hr-HR')}
%head
%title Some title
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}/
%meta{'name' => "description", :content => 'Some title - YO!'}/
= stylesheets
= javascripts('test', :other)
%body
= yield
Run Code Online (Sandbox Code Playgroud)
产生以下:
<?xml version='1.0' encoding='utf-8' ?>
<html lang='hr-HR' xml:lang='hr-HR' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Some title</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<meta content='Some title - YO!' name='description' />
<link href="stylesheets/application.css" media="all" rel="stylesheet" type="text/css"/><link href="stylesheets/grid.css" media="all" rel="stylesheet" type="text/css"/><link href="stylesheets/text.css" media="all" rel="stylesheet" type="text/css"/>
<script language="javascript" src="javascripts/test.js" type="text/javascript"></script><script language="javascript" src="javascripts/other.js" type="text/javascript"></script>
</head>
<body>
<h1>some …Run Code Online (Sandbox Code Playgroud) 使用HAML的(有意)奇怪的多行格式,我想在我的模板中有以下几行:
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
-# and
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
Run Code Online (Sandbox Code Playgroud)
但是,它们不能相互碰撞,或者它们被读作单个多行块.
-# This fails:
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 => 'bar5' |
= call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', |
:foo4 => 'bar4', :foo5 …Run Code Online (Sandbox Code Playgroud) 我有一个简单的sinatra应用程序,使用haml和sass的视图.其中一个视图(位于视图文件夹中)是我的导航菜单的一部分.我试图从index.haml渲染它,但我得到以下错误:错误的参数数量(1为2)
我试图用index.haml中的以下行来渲染它
.navigation
= render :partial => "nav"
Run Code Online (Sandbox Code Playgroud) haml ×10
ruby ×3
sass ×2
actionmailer ×1
compass-sass ×1
css ×1
django ×1
html ×1
python ×1
sinatra ×1
staticmatic ×1
textmate ×1
view ×1
word-wrap ×1