sass的"font-url"在哪里?方法得到定义? [英] Where does the sass "font-url" method get defined?

查看:184
本文介绍了sass的"font-url"在哪里?方法得到定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bourbon 使用font-url Rails具有方法font_url,我相当确定这是正在调用的方法.但是,我找不到这两件事之间的联系.我已经探究了bourbon,sass,sass-rais和rails的代码库.

Rails has the method font_url which I'm fairly certain is what is being invoked. However, I can't find where the connection between these two things is made. I have explored the codebases of bourbon, sass, sass-rais, and rails.

font-url在哪里定义,和/或在它与rails font_url之间建立连接?

Where is font-url defined, and/or the connection between it and rails's font_url made?

更新

澄清:我的最终目标是在rubyland中定义自己的助手,它们是font_url的同级兄弟.

Clarification: my ultimate goal is to define my own helpers in rubyland which are siblings to font_url.

推荐答案

font-url是rails资产管道的一部分,就像image-url 一样.如果您查看 rail guides ,则会清楚地说明

font-url is a part of rails asset pipeline just like image-url. If you look at rail guides it clearly says

使用资产管道时,必须重新编写资产路径,并且sass-rails为以下资产类别提供-url和-path帮助器(在Sass中带连字符,在Ruby中加强调):图像,字体,视频,音频,JavaScript和样式表.

When using the asset pipeline, paths to assets must be re-written and sass-rails provides -url and -path helpers (hyphenated in Sass, underscored in Ruby) for the following asset classes: image, font, video, audio, JavaScript and stylesheet.

因此,如果您使用的是 font-url("some_font"),它将在app/assets/font目录中查找some_font

So if you are using font-url("some_font") it will look for some_font in app/assets/font directory

更新:

正如文档中提到的那样,如果您使用的是sass ,那么您可以将资产与混合的url(image-url)一起使用,但是如果您使用的是ruby文件,则

As it is mentioned in docs that if you are using sass then your can use your assets with hypenated urls(image-url) but if you are using a ruby file then those helpers would be underscored (image_url) probably because Ruby doesn't like you having methods or variables with hyphens in the name syntactically, but semantically, there's nothing wrong with it

这篇关于sass的"font-url"在哪里?方法得到定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆