erlydtl_ext.hrl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. -record(error_info, {
  2. return = false,
  3. report = false,
  4. list = []
  5. }).
  6. -record(dtl_context, {
  7. local_scopes = [],
  8. block_dict = dict:new(),
  9. trans_fun = none,
  10. trans_locales = [],
  11. auto_escape = [off],
  12. doc_root = "",
  13. parse_trail = [],
  14. vars = [],
  15. const = [],
  16. record_info = [],
  17. filters = [],
  18. tags = [],
  19. libraries = [],
  20. custom_tags_dir = [],
  21. reader = {file, read_file},
  22. reader_options = [],
  23. module = undefined,
  24. compiler_options = [],
  25. binary_strings = true,
  26. force_recompile = false,
  27. verbose = 0,
  28. is_compiling_dir = false,
  29. extension_module = undefined,
  30. scanner_module = erlydtl_scanner,
  31. scanned_tokens = [],
  32. all_options = [],
  33. errors = #error_info{},
  34. warnings = #error_info{},
  35. bin = undefined,
  36. lists_0_based = false,
  37. tuples_0_based = false,
  38. checks = [non_block_tag]
  39. }).
  40. %% ALL fields of ast_info{} must be lists (see erlydtl_compiler_utils:merge_info/2)
  41. -record(ast_info, {
  42. dependencies = [],
  43. translatable_strings = [],
  44. translated_blocks= [],
  45. custom_tags = [],
  46. var_names = [],
  47. def_names = [],
  48. const_names = []
  49. }).
  50. -record(treewalker, {
  51. counter = 0,
  52. safe = false,
  53. extension = undefined,
  54. context
  55. }).
  56. -record(scanner_state, {
  57. template=[],
  58. scanned=[],
  59. pos={1,1},
  60. state=in_text
  61. }).
  62. -define(ERR(Err, Ctx), erlydtl_compiler_utils:add_error(?MODULE, Err, Ctx)).
  63. -define(WARN(Warn, Ctx), erlydtl_compiler_utils:add_warning(?MODULE, Warn, Ctx)).
  64. -define(V_INFO,1).
  65. -define(V_DEBUG,2).
  66. -define(V_TRACE,3).
  67. -define(LOG_INFO(Fmt, Args, Ctx), erlydtl_compiler_utils:print(?V_INFO, Fmt, Args, Ctx)).
  68. -define(LOG_DEBUG(Fmt, Args, Ctx), erlydtl_compiler_utils:print(?V_DEBUG, Fmt, Args, Ctx)).
  69. -define(LOG_TRACE(Fmt, Args, Ctx), erlydtl_compiler_utils:print(?V_TRACE, Fmt, Args, Ctx)).
  70. -ifndef(OTP_RELEASE).
  71. -define(WITH_STACKTRACE(T, R, S), T:R -> S = erlang:get_stacktrace(), ).
  72. -else.
  73. -define(WITH_STACKTRACE(T, R, S), T:R:S ->).
  74. -endif.