You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we only support nested and compressed output. But these currently do not share a common parent class. IMO we should create such a base class for all output styles, which will implement all common parts.
Abstract the output buffer and provide a simple API
Source-maps should be created automatically
The UTF-8 charset should be added automatically
Makes it easier to implement other output styles
I already made some experiments when implementing the charset feature.
It should be usable as a starting point, if someone else wants to start with it:
#file: output.hpp
#defineSASS_OUTPUT#ifndefSASS_OPERATION#include"operation.hpp"#endif#ifndefSASS_CONTEXT#include"context.hpp"#endif#include<string>namespaceSass {
usingnamespacestd;
structContext;
template<typenameT>classOutput : publicOperation_CRTP<void, T> {
// import all the class-specific methods and override as desiredusingOperation_CRTP<void, T>::operator();
protected:
Context*ctx;
stringbuffer;
stringrendered_imports;
boolseen_utf8;
virtualvoidfallback_impl(AST_Node*n) =0;
public:
Output(Context*ctx=0)
: ctx(ctx),
buffer(""),
rendered_imports(""),
seen_utf8(false)
{ }
virtual ~Output() { };
stringget_buffer()
{
returnrendered_imports+buffer;
}
// append some text or token to the buffer// it is the main function for source-mappingvoidappend_buffer(conststring&data)
{
// search for unicode charfor(constchar&chr : data) {
// abort clauseif (seen_utf8) break;
// skip all normal ascii charsif (chr >= 0&&chr<128) continue;
// prepend charset to bufferbuffer="@charset \"UTF-8\";\n"+buffer;
// singletonseen_utf8= true;
}
// add to bufferbuffer+=data;
// account for data in source-mapsctx->source_map.update_column(data);
}
};
}
I was not able to implement this outside the header, which is probably because my c++ template foo is not very good. Maybe someone else knows if this is the only/right way?
The text was updated successfully, but these errors were encountered:
Speaking of refactoring the code, would it make sense to also restructure the repo: separate .cs and .cpps from .hs and .hpps like so:
root
\
libsass
\
sources
\
{ all source files go here, could have subdirectories }
\
headers
\
{ all header files go here, could have subdirectories matching those under sources }
This way the README would be visible without scrolling down the repo's main page. 😄
Currently we only support nested and compressed output. But these currently do not share a common parent class. IMO we should create such a base class for all output styles, which will implement all common parts.
#717: Main reasons (beside DRY):
I already made some experiments when implementing the charset feature.
It should be usable as a starting point, if someone else wants to start with it:
I was not able to implement this outside the header, which is probably because my c++ template foo is not very good. Maybe someone else knows if this is the only/right way?
The text was updated successfully, but these errors were encountered: