我正在尝试使用cfstatic.在我的index.cfm中,我只使用cfstatic添加green.css,cfstatic应该只添加green.css的最小化版本,所以我的h1文本<h1>I should be Green</h1>应该是绿色.但cfstatic正在添加green.css和red.css.我错过了配置吗?
的Application.cfc
component output="false"{
This.name = "testing";
This.sessionManagement = true;
This.sessionTimeout = CreateTimeSpan(1, 23, 59, 59);
This.mappings["/org"] = expandpath('.')&'\org';
function onRequestStart(){
application.cfstatic = CreateObject( 'org.cfstatic.CfStatic' )
.init( staticDirectory = ExpandPath('./assets'),
staticUrl = "/cfstatic/assets/"
);
}
}
Run Code Online (Sandbox Code Playgroud)
Index.cfm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<cfscript>
application.cfstatic.include( '/css/green.css',true );
</cfscript>
<cfoutput>#application.cfstatic.renderIncludes('css')#</cfoutput>
</head>
<body>
<h1>I should be Green</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Green.css
/* This is assets/css/green.css */
h1 {color:green;}
Run Code Online (Sandbox Code Playgroud)
Red.css
/* This is assets/css/red.css */ …Run Code Online (Sandbox Code Playgroud) 更新:提交了此问题的错误报告,Bug#4150051
您可以调用?:作为elvis运算符/三元运算符/ null coelcing.在ACF中关于此运算符的适当文档的实现和运气非常差.在TestBox中使用它时遇到了一些问题(试过v2.3.0 + 00044和2.2.0 + 00021)BDD.在这里,我创建了非常简单的测试包(aTest.cfc)来演示这个问题.
component extends="testbox.system.BaseSpec"{
function run(){
describe( "checking the ACF issues in ternary operaors", function(){
it( "Just dump, it will pass. But see the dump above", function(){
itemTypeConfig = {};
writeDump( itemTypeConfig.someConfig ?: "I am null" );
itemTypeConfig = {"someConfig":"abcd"};
writeDump( itemTypeConfig.someConfig ?: "I am null" );
} );
it( "Check with elvis operator inside expect", function(){
itemTypeConfig = {};
expect( itemTypeConfig.someConfig ?: "I am null" ).toBe(1);
itemTypeConfig = {"someConfig":"abcd"};
expect( itemTypeConfig.someConfig ?: …Run Code Online (Sandbox Code Playgroud)