首页 \ 问答 \ 通过http导入SASS部分而不是文件系统(import SASS partial over http instead of filesystem)

通过http导入SASS部分而不是文件系统(import SASS partial over http instead of filesystem)

我有一个rails项目,我想根据用户变量动态创建一个sass文件(作为用户自定义站点的一种方式)。 我需要通过http将@import该文件导入到网站的主sass文件中,因为它是动态生成的,而不是实际写入文件系统。

如何配置:load_paths指令告诉SASS通过http而不是通过文件系统查找该文件?

文档说这是可能的,但我在网上找不到任何例子。 http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#custom_importers


I have a rails project where I want to dynamically create a sass file based on user variables, (as a way for users to customize the site). I need to @import that file into the site's main sass file through http, since it's dynamically generated and not actually written to the filesystem.

How do I configure the :load_paths directive to tell SASS to look for that file over http instead of through the filesystem?

The documentation says it's possible but I can't find any examples online. http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#custom_importers


原文:https://stackoverflow.com/questions/6857988
更新时间:2024-01-09 13:01

最满意答案

您可以使用Racket 序列化库来执行此操作。 这是一个例子:

Welcome to Racket v6.4.0.7.
-> (require racket/serialize)
-> (with-output-to-file "/tmp/set.rktd"
     (lambda () (write (serialize (set 1 2 3)))))
-> (with-input-from-file "/tmp/set.rktd"
     (lambda () (deserialize (read))))
(set 1 3 2)

请注意,序列化值只是一种特殊的s表达式,因此您可以像其他值一样对其进行操作(例如将其存储在数据库中,将其写入磁盘,通过网络发送等):

-> (serialize (set 1 2 3))
'((3)
  1
  (((lib "racket/private/set-types.rkt")
    .
    deserialize-info:immutable-custom-set-v0))
  0
  ()
  ()
  (0 #f (h - (equal) (1 . #t) (3 . #t) (2 . #t))))

You can use the Racket serialization library to do this. Here's an example:

Welcome to Racket v6.4.0.7.
-> (require racket/serialize)
-> (with-output-to-file "/tmp/set.rktd"
     (lambda () (write (serialize (set 1 2 3)))))
-> (with-input-from-file "/tmp/set.rktd"
     (lambda () (deserialize (read))))
(set 1 3 2)

Note that a serialized value is just a special kind of s-expression, so you can manipulate it like other values (like store it in a database, write it to disk, send it over a network, etc.):

-> (serialize (set 1 2 3))
'((3)
  1
  (((lib "racket/private/set-types.rkt")
    .
    deserialize-info:immutable-custom-set-v0))
  0
  ()
  ()
  (0 #f (h - (equal) (1 . #t) (3 . #t) (2 . #t))))

相关问答

更多
  • 在list使用cdr时,它表示“列表的其余部分”。 列表的其余部分始终是list , 而不是 list的单个元素。 如果你想要列表xy的第二个元素 ,那么你需要使用cadr 。 (你也可以使用second 。) (define xy (list 1 2 3)) (cdr xy) ; '(2 3) (cadr xy) ; 2 (second xy) ; 2 When you use cdr on a list, it means "the rest of the list". The re ...
  • 有很多方法可以做到这一点。 我会给你三个。 选项1:使用内置read read函数读取s表达式。 方便的是,整数是有效的s表达式,它也会跳过空格。 这意味着您只需在输入端口上调用两次以生成两个基准: > (let ([in (open-input-string "1 2")]) (values (read in) (read in))) 1 2 这有一个缺点:有很多东西都是有效的s表达式而不是数字,所以如果你不小心你可能会得到很多垃圾。 例如: > (let ([in (open-input-st ...
  • 文档是你最好的朋友。 它非常简单: check-expect的第一个参数是要测试的表达式或过程,第二个是预期的结果(因此是名称)。 假设您选择了适当的语言(例如: Beginning Student ) (check-expect (+ 1 1) 2) (check-expect (+ 1 1) 1) 以上将产生如下输出: Ran 2 tests. 1 of the 2 tests failed. No signature violations. Check failures: Actual ...
  • 您可以使用Racket 序列化库来执行此操作。 这是一个例子: Welcome to Racket v6.4.0.7. -> (require racket/serialize) -> (with-output-to-file "/tmp/set.rktd" (lambda () (write (serialize (set 1 2 3))))) -> (with-input-from-file "/tmp/set.rktd" (lambda () (deserialize (read) ...
  • 我在Emacs遇到了同样的问题,然后我将配置代码更改为 (require 'racket-mode) (setq racket-racket-program "C:/Program Files/Racket/racket.exe") (setq racket-raco-program "C:/Program Files/Racket/raco.exe") 将程序路径更改为绝对路径。 然后错误消失。 我希望对你有用。 I met the same problem at Emacs, and then I c ...
  • dot并不是一个独特的球拍,而是一个lisp的东西。 列表由成对组成,一对具有文字形式(car . cdr) ,元素2, 3的列表组成如(2 . (3 . ())) ,读者可以读取此内容,但是一个有一对的列表,因为它的cdr可以显示没有点和parens使得(2 . (3 . ()))与(2 3 . ()) 。 也可以省略最后带有特殊空列表的点,以便(2 3)可以读取它,并且display唯一的方式,REPL将打印它。 如果你没有一对或null作为cdr什么? 那么表示它的唯一方法就是点缀。 使用(2 . ( ...
  • 我没有安装模块。 我在5.3,并且该模块仅在5.3.2之后存在 I did not have the module installed. I was on 5.3, and the module existed only since 5.3.2
  • 是的,您可以通过将自定义entry-reader参数传递给unzip-entry来执行此操作。 以下是如何执行此操作的示例: (define (unzip-entry->bytes path zipdir entry) (call-with-output-bytes (lambda (out) (unzip-entry path zipdir entry (lambda (name dir? in) (copy- ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)