2011-09-28 2 views

답변

32

우리가 찾을 :

# Returns a 200 OK response tuple 
    def ok_response(asset, env) 
    if body_only?(env) 
     [ 200, headers(env, asset, Rack::Utils.bytesize(asset.body)), [asset.body] ] 
    else 
     [ 200, headers(env, asset, asset.length), asset ] 
    end 
    end 

body_only?가 설정되어있는 고정 자산에 대한 ?body=1 or true

, Asset.body는 다음과 같이 정의 할 때 :

def body 
    # File is read everytime to avoid memory bloat of large binary files 
    pathname.open('rb') { |f| f.read } 
end 

반면 그 자산을 다시 자기 자신에게 넘겨 준다. 는 "랙있는 몸 개체"

# Add enumerator to allow `Asset` instances to be used as Rack 
# compatible body objects. 
def each 
    yield to_s 
end 

우리가 bundled_asset에서 찾습니다 Asset.body 만이 아니라 종속성을 포함한 자산의 신체를 검색으로 재정의된다. Asset.to_a은 자체 자산 및 모든 종속성을 랙으로 전달 된 배열로 검색하는 것으로 정의됩니다.

이렇게하면 애셋이 함께 결합되지 않고 개별 개체로 간주되므로 개별 CSS 파일은 여전히 ​​개별적입니다.

관련 문제