通过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
最满意答案
您可以使用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))))
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
在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 ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
有很多方法可以做到这一点。 我会给你三个。 选项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 ...
-
检查Racket中的例子(Check expect example in Racket)[2023-08-23]
文档是你最好的朋友。 它非常简单: 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 ...
-
圆点在Racket中做什么?(What does the dot do in Racket?)[2022-03-09]
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- ...